// Update an existing Session // PUT /api/recipes/ public HttpResponseMessage Put(Recipe recipe) { Uow.Recipes.Update(recipe); Uow.Commit(); return new HttpResponseMessage(HttpStatusCode.NoContent); }
// Create a new Session // POST /api/recipes public HttpResponseMessage Post(Recipe recipe) { Uow.Recipes.Add(recipe); Uow.Commit(); var response = Request.CreateResponse(HttpStatusCode.Created, recipe); // Compose location header that tells how to get this session // e.g. ~/api/session/5 response.Headers.Location = new Uri(Url.Link(WebApiConfig.ControllerAndId, new { id = recipe.Id })); return response; }