Ejemplo n.º 1
0
 /**
  * @throws EntityValidationException
  * @return void
  */
 public function sell()
 {
     if ($this->SoldOut()) {
         throw new EntityValidationException(EntityValidationException::buildMessage('Sold Out'));
     }
     $this->CurrentlyAvailable -= 1;
 }
 /**
  * @param $purchase_order_id
  * @param IMessageSenderService $rejected_purchase_order_message_sender
  * @throws EntityValidationException
  * @throws NotFoundEntityException
  * @return void
  */
 public function rejectPurchaseOrder($purchase_order_id, IMessageSenderService $rejected_purchase_order_message_sender)
 {
     $repository = $this->repository;
     $this->tx_manager->transaction(function () use($purchase_order_id, $repository, $rejected_purchase_order_message_sender) {
         $purchase_order = $repository->getById($purchase_order_id);
         if (is_null($purchase_order)) {
             throw new NotFoundEntityException('SummitPackagePurchaseOrder', sprintf('id %d', $purchase_order_id));
         }
         if ($purchase_order->isApproved()) {
             throw new EntityValidationException(EntityValidationException::buildMessage(sprintf('order id %s is already approved!', $purchase_order_id)));
         }
         if ($purchase_order->isRejected()) {
             throw new EntityValidationException(EntityValidationException::buildMessage(sprintf('order id %s is already rejected!', $purchase_order_id)));
         }
         $purchase_order->reject($rejected_purchase_order_message_sender);
     });
 }
Ejemplo n.º 3
0
 /**
  * @param ISummit $summit
  * @param ISummitEvent $event
  * @return mixed
  */
 public function unpublishEvent(ISummit $summit, ISummitEvent $event)
 {
     $event_repository = $this->event_repository;
     return $this->tx_service->transaction(function () use($summit, $event, $event_repository) {
         if (intval($event->SummitID) !== intval($summit->getIdentifier())) {
             throw new EntityValidationException(EntityValidationException::buildMessage('event doest not belongs to summit'));
         }
         $event->unPublish();
         return $event;
     });
 }