// POST beers public HttpResponseMessage Post(BeerRepresentation value) { var newBeer = new Beer(value.Name); repository.Add(newBeer); return new HttpResponseMessage(HttpStatusCode.Created) { Headers = { Location = LinkTemplates.Beers.Beer.CreateUri(new { id = newBeer.Id }) } }; }
// POST api/beers public HttpResponseMessage Post(BeerRepresentation value) { var newBeer = new Beer(value.Name); beerDbContext.Beers.Add(newBeer); beerDbContext.SaveChanges(); return new HttpResponseMessage(HttpStatusCode.Created) { Headers = { Location = LinkTemplates.Beers.Beer.CreateUri(id => newBeer.Id) } }; }