public ActionResult <ReviewReadDto> CreateReview(ReviewCreateDto reviewCreateDto) { var reviewModel = mapper.Map <Review>(reviewCreateDto); reviewRepo.CreateReview(reviewModel); reviewRepo.SaveChanges(); var reviewReadDto = mapper.Map <ReviewReadDto>(reviewModel); return(CreatedAtRoute(nameof(GetReviewById), new { Id = reviewReadDto.FacultyId }, reviewReadDto)); }
public IActionResult PutReview(int userId, int recipeId, Review review) { if (userId != review.UserId || recipeId != review.RecipeId) { _logger.LogWarning($"Route values: user id: {userId} and recipe id: {recipeId} does not " + $"match Review user id: {review.UserId} and Review recipe id: {review.RecipeId}"); return(BadRequest()); } if (!ReviewExists(userId, recipeId)) { _logger.LogWarning($"Review with user id: {userId} and recipe id: {recipeId} does not exist."); return(NotFound()); } _reviewRepo.UpdateReview(review); _reviewRepo.SaveChanges(); _logger.LogInformation($"Review with user id: {userId} and recipe id: {recipeId} has been updated."); return(NoContent()); }