public HttpResponseMessage Post(AddContactCommand command) { var newId = contacts.Max(x => x.Id) + 1; var contact = new Contact { Id = newId, FirstName = command.FirstName, LastName = command.LastName, Email = command.Email }; contacts.Add(contact); var response = Request.CreateResponse(HttpStatusCode.Created, contact); response.Headers.Location = new Uri(Url.Link("DefaultApi", new { controller = "contacts", id = contact.Id })); return(response); }
public HttpResponseMessage Post(AddContactCommand command) { var newId = contacts.Max(x => x.Id) + 1; var contact = new Contact { Id = newId, FirstName = command.FirstName, LastName = command.LastName, Email = command.Email }; contacts.Add(contact); var response = Request.CreateResponse(HttpStatusCode.Created, contact); response.Headers.Location = new Uri(Url.Link("DefaultApi", new { controller = "contacts", id = contact.Id })); return response; }