public async Task <IActionResult> LikeReview(int reviewId, string reviewerName, bool like) { var reviewerResponse = await _reviewerData.GetReviewer(reviewerName); if (!reviewerResponse.IsSuccessful) { return(null); } var reviewResponse = await _reviewData.LikeReview( reviewId, reviewerResponse.Data.Id, like); if (!reviewResponse.IsSuccessful) { return(null); } return(Json(reviewResponse.Data)); }
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)); }