Created
May 24, 2012 09:27
-
-
Save glennblock/2780448 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 HttpResponseMessage Post(Customer customer) { | |
repo.Add(customer); | |
repo.SaveChanges(); | |
var response = Request.CreateResponse(HttpStatusCode.Created, customer); | |
response.Headers.Location = new Uri(Request.RequestUri, string.format("customer/{0}", customer.id)); | |
return response; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment