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);
        }
Example #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,
                Links =
                {
                    LinkTemplates.BeerStyles.AssociatedBeers.CreateLink(new{id=beerStyle.Id})
                }
            };

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