Ejemplo n.º 1
0
        public ActionResult <ItemResponse <AverageProductRating> > GetConsumerProductRatingByEntityId(int entityId)
        {
            ActionResult result = null;

            try
            {
                AverageProductRating rating = _ratingsService.GetAvgConsumerProductRatingByEntityId(entityId);

                if (rating == null)
                {
                    result = NotFound404(new ErrorResponse("You do not have any product ratings to display"));
                }
                else
                {
                    ItemResponse <AverageProductRating> resp = new ItemResponse <AverageProductRating>();
                    resp.Item = rating;
                    result    = Ok200(resp);
                }
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.ToString());
                result = StatusCode(500, new ErrorResponse(ex.Message.ToString()));
            }

            return(result);
        }