-
-
Save TWolverson/e33757de74472c1c007b3653c9a8b1c8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CustomersController | |
{ | |
private readonly IQueryable<Customer> customersQuery; | |
public CustomersController(IQueryable<Customer> customersQuery) | |
{ | |
this.customersQuery = customersQuery; | |
} | |
public Customer Get(int id) | |
{ | |
try | |
{ | |
return customerQuery.Single(customer => customer.Id = id); | |
} | |
catch(InvalidOperationException e) | |
{ | |
return NotFound(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment