Skip to content

Instantly share code, notes, and snippets.

@glennblock
Created May 24, 2012 09:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glennblock/2780444 to your computer and use it in GitHub Desktop.
Save glennblock/2780444 to your computer and use it in GitHub Desktop.
public class CustomerController : ApiController {
private ICustomerContext repo;
public CustomerController(ICustomerContext repo) {
this.repo = repo;
}
public Customer Get(int id) {
var customer = repo.Customers.SingleOrDefault(c=>c.CustomerID == id);
if (customer == null) {
throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound));
}
return customer;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment