示例#1
0
        // 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 })
                }
            };
        }
示例#2
0
        // 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)
                }
            };
        }