public async Task <IActionResult> GetReview(int id, [FromQuery] string fields)
        {
            if (!_typeHelperService.TypeHasProperties <ReviewReturnModel>(fields))
            {
                return(BadRequest());
            }

            var review = await _reviewData.GetReview(id);

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

            var returnModel = Mapper.Map <ReviewReturnModel>(review);

            var links = CreateLinksForReview(id, fields);

            var returnModelWithLinks = returnModel.ShapeData(fields)
                                       as IDictionary <string, object>;

            returnModelWithLinks.Add("links", links);

            return(Ok(returnModelWithLinks));
        }
示例#2
0
        public async Task <IActionResult> Review(string resourceUrl, int?id)
        {
            IRestResponse <Review> response = await _reviewData.GetReview(resourceUrl, id);

            if (!response.IsSuccessful)
            {
                return(View("Error", new ErrorViewModel(response.ErrorMessage,
                                                        response.ErrorException.ToString())));
            }

            return(View(response.Data));
        }