public async Task <ReviewSettings> GetReviewSettingsAsync(int reviewId, int userId, int?versionId = null) { var revisionId = await _itemInfoRepository.GetRevisionId(reviewId, userId, versionId); var reviewInfo = await GetReviewInfoAsync(reviewId, userId, revisionId); if (!await _permissionsRepository.HasReadPermissions(reviewId, userId, revisionId: revisionId)) { throw ReviewsExceptionHelper.UserCannotAccessReviewException(reviewId); } var reviewData = await _reviewsRepository.GetReviewAsync(reviewId, userId, revisionId); return(await GetReviewSettingsFromReviewData(reviewData, reviewInfo)); }
public async Task <Review> AddLodgmentReviewAsync(int id, Review reviewModel) { var booking = await bookingService.GetBookingStatusAsync(reviewModel.ConfirmationCode); if (booking == null) { throw new KeyNotFoundException("El código de reserva no existe."); } var review = await repository.GetReviewAsync(reviewModel.ConfirmationCode); if (review != null) { throw new ArgumentException("El código de reserva ya fue usado."); } reviewModel.LodgmentId = id; reviewModel.Name = booking.Name; review = await repository.AddLodgmentReviewAsync(reviewModel); return(review); }