public ActionResult <BeerStyleRepresentation> Get(int id)
        {
            var beerStyle = beerDbContext.BeerStyles.SingleOrDefault(s => s.Id == id);

            if (beerStyle == null)
            {
                return(NotFound());
            }

            var beerStyleResource = new BeerStyleRepresentation
            {
                Id   = beerStyle.Id,
                Name = beerStyle.Name
            };

            return(beerStyleResource);
        }
Beispiel #2
0
        public HttpResponseMessage Get(int id)
        {
            var beerStyle = beerDbContext.Styles.SingleOrDefault(s => s.Id == id);

            if (beerStyle == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            var beerStyleResource = new BeerStyleRepresentation
            {
                Id   = beerStyle.Id,
                Name = beerStyle.Name
            };

            return(Request.CreateResponse(HttpStatusCode.OK, beerStyleResource));
        }