public async Task <IActionResult> Review(UserReviewRequestModel userReviewRequestModel) { userReviewRequestModel.UserId = Convert.ToInt32(HttpContext.User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value); var newReview = await _userService.Review(userReviewRequestModel); return(LocalRedirect("~/")); }
public async Task <IActionResult> Review(UserReviewRequestModel userReviewRequestModel) { userReviewRequestModel.UserId = Convert.ToInt32(HttpContext.User.Claims.FirstOrDefault(u => u.Type == ClaimTypes.NameIdentifier).Value); var createReview = await _reviewService.CreateReview(userReviewRequestModel); return(LocalRedirect("~/Movies/Details/" + userReviewRequestModel.MovieId)); }
public async Task <Review> Review(UserReviewRequestModel userReviewRequestModel) { var review = new Review { MovieId = userReviewRequestModel.MovieId, UserId = userReviewRequestModel.UserId, Rating = userReviewRequestModel.Rating, ReviewText = userReviewRequestModel.ReviewText }; return(await _reviewRepository.AddAsync(review)); }
public async Task <Review> CreateReview(UserReviewRequestModel userReviewRequestModel) { if (await IsMovieReviewed(userReviewRequestModel.UserId, userReviewRequestModel.MovieId) == true) { throw new Exception("You have already reviewed this movie"); } var review = new Review() { MovieId = userReviewRequestModel.MovieId, UserId = userReviewRequestModel.UserId, Rating = userReviewRequestModel.Rating, ReviewText = userReviewRequestModel.ReviewText }; var createReview = await _reviewRepository.AddAsync(review); return(review); }