コード例 #1
0
 public Review Create(Review review, Guid idOfReserveAssociated)
 {
     try
     {
         Reserve reserveAssociated = reserveManagementLogic.GetById(idOfReserveAssociated);
         VerifyIfExistReviewForReserve(idOfReserveAssociated);
         review.IdOfReserve           = idOfReserveAssociated;
         review.NameOfWhoComments     = reserveAssociated.Name;
         review.LastNameOfWhoComments = reserveAssociated.LastName;
         Lodging lodgingOfReview = reserveAssociated.LodgingOfReserve;
         review.LodgingOfReview = lodgingOfReview;
         review.VerifyFormat();
         reviewRepository.Add(review);
         double averageReviewScoreUpdated = reviewRepository.GetAverageReviewScoreByLodging(lodgingOfReview.Id);
         lodgingManagementLogic.UpdateAverageReviewScore(lodgingOfReview, averageReviewScoreUpdated);
         return(review);
     }
     catch (ReviewException e)
     {
         throw new DomainBusinessLogicException(e.Message);
     }
     catch (ClientBusinessLogicException e)
     {
         throw new ClientBusinessLogicException(MessageExceptionBusinessLogic.ErrorCreatingReview, e);
     }
     catch (DomainBusinessLogicException e)
     {
         throw new DomainBusinessLogicException(e.Message);
     }
     catch (ServerException e)
     {
         throw new ServerBusinessLogicException("No se puede crear la review debido a que ha ocurrido un error.", e);
     }
 }
コード例 #2
0
 public IActionResult Get(Guid id)
 {
     try
     {
         Reserve reserve = reserveManagement.GetById(id);
         return(Ok(ReserveModelForResponse.ToModel(reserve)));
     }
     catch (ClientBusinessLogicException e)
     {
         return(NotFound(e.Message));
     }
     catch (ServerBusinessLogicException e)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
     }
 }