public async Task <IHttpActionResult> AddRating(int id, ReviewDTO reviewDTO)
        {
            if (!ModelState.IsValid)
            {
                var message = string.Join(" | ", ModelState.Values
                                          .SelectMany(v => v.Errors)
                                          .Select(e => e.ErrorMessage));
                return(Json(new { message }));
            }

            Boolean isIdValid = await APIHelper.ValidateID(id);

            if (!isIdValid)
            {
                return(BadRequest("No beer exists with id '" + id + "'"));
            }

            BeerReview review = new BeerReview
            {
                id       = id,
                Username = reviewDTO.Username,
                Rating   = reviewDTO.Rating,
                Comments = reviewDTO.Comments
            };

            DatabaseReadWrite.AddReview(review);

            return(Ok("Review Added to database"));
        }
        public async Task <IHttpActionResult> GetReviewsByBeerName(String name)
        {
            if (String.IsNullOrEmpty(name))
            {
                return(BadRequest("Input parameter name is null or empty"));
            }
            var beers = await APIHelper.GetBeerByName(name);

            var reviews = DatabaseReadWrite.FetchAllReviews();

            var beerReviews = from b in beers
                              join r in reviews
                              on b.id equals r.id into br
                              select new
            {
                Id          = b.id,
                Name        = b.name,
                Description = b.description,
                UserRatings = ConvertToReviews(br)
            };

            return(Ok(beerReviews));
        }