/**
  * @param ReservationSeries|ExistingReservationSeries $series
  * @return IReservationValidationResult
  */
 public function Validate($series)
 {
     $result = $this->serviceToDecorate->Validate($series);
     // don't bother validating this rule if others have failed
     if (!$result->CanBeSaved()) {
         return $result;
     }
     return $this->EvaluateCustomRule($series);
 }
示例#2
0
 /**
  * @param ReservationSeries $reservationSeries
  * @param IReservationSaveResultsView $view
  * @return bool if the reservation was handled or not
  */
 public function Handle(ReservationSeries $reservationSeries, IReservationSaveResultsView $view)
 {
     $validationResult = $this->validationService->Validate($reservationSeries);
     $result = $validationResult->CanBeSaved();
     if ($validationResult->CanBeSaved()) {
         try {
             $this->persistenceService->Persist($reservationSeries);
         } catch (Exception $ex) {
             Log::Error('Error saving reservation: %s', $ex);
             throw $ex;
         }
         $this->notificationService->Notify($reservationSeries);
         $view->SetSaveSuccessfulMessage($result);
     } else {
         $view->SetSaveSuccessfulMessage($result);
         $view->SetErrors($validationResult->GetErrors());
     }
     $view->SetWarnings($validationResult->GetWarnings());
     return $result;
 }
 public function Validate($reservationSeries)
 {
     return $this->ruleProcessor->Validate($reservationSeries);
 }