public async Task <IActionResult> MyReviews(string resourceUrl, int pageNumber = 1) { IRestResponse <Reviewer> response1 = await _reviewerData.GetReviewer(User.Identity.Name); IRestResponse <List <Review> > response2 = await _reviewData.GetMyReviews(response1.Data.Id, pageNumber, pageSize, resourceUrl); if (!response2.IsSuccessful) { return(View("Error", new ErrorViewModel(response2.ErrorMessage, response2.ErrorException.ToString()))); } ViewBag.PaginationMetadata = JsonConvert.DeserializeObject(response2.Headers .FirstOrDefault(h => h.Name == "X-Pagination").Value.ToString()); return(View(response2.Data)); }
public async Task <IActionResult> GetReviewer(string username, int?id) { var reviewer = await _reviewerData.GetReviewer(username, id); if (reviewer == null) { return(NotFound()); } var returnModel = Mapper.Map <ReviewerReturnModel>(reviewer); return(Ok(returnModel)); }
public async Task <IActionResult> LikeReview([FromRoute] int reviewId, [FromQuery] int reviewerId, [FromQuery] bool like) { var review = await _reviewData.GetReview(reviewId); var reviewer = await _reviewerData.GetReviewer(null, reviewerId); if (review == null || reviewer == null) { return(NotFound()); } if (review.NumberOfLikes == 0 && like == false) { return(BadRequest()); } await _reviewData.LikeReview(reviewId, reviewerId, like); var returnModel = Mapper.Map <ReviewReturnModel>(review); return(Ok(returnModel)); }