Created
May 24, 2012 09:25
-
-
Save glennblock/2780444 to your computer and use it in GitHub Desktop.
This file contains 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 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