Exemplo n.º 1
0
 public function handle(UpdateCouponCommand $command)
 {
     $couponDTO = $command->getCouponDTO();
     $coupon = $this->couponService->findOneById($couponDTO->id);
     CouponDTOBuilder::setFromDTO($coupon, $couponDTO);
     $this->couponService->update($coupon);
 }
Exemplo n.º 2
0
 public function handle(ListCouponsQuery $query)
 {
     $request = $query->getRequest();
     $response = $query->getResponse();
     $paginationDTO = $request->getPaginationDTO();
     $pagination = new Pagination($paginationDTO->maxResults, $paginationDTO->page);
     $coupons = $this->couponService->getAllCoupons($request->getQueryString(), $pagination);
     $response->setPaginationDTOBuilder($this->dtoBuilderFactory->getPaginationDTOBuilder($pagination));
     foreach ($coupons as $coupon) {
         $response->addCouponDTOBuilder($this->dtoBuilderFactory->getCouponDTOBuilder($coupon));
     }
 }
Exemplo n.º 3
0
 public function handle(CreateCouponCommand $command)
 {
     $coupon = new Coupon($command->getCode(), $command->getCouponId());
     $coupon->setFlagFreeShipping($command->getFlagFreeShipping());
     $coupon->setMinOrderValue($command->getMinOrderValue());
     $coupon->setMaxOrderValue($command->getMaxOrderValue());
     $coupon->setCanCombineWithOtherCoupons($command->canCombineWithOtherCoupons());
     $coupon->setName($command->getName());
     $coupon->setType(PromotionType::createById($command->getPromotionTypeId()));
     $coupon->setValue($command->getValue());
     $coupon->setReducesTaxSubtotal($command->getReducesTaxSubtotal());
     $coupon->setMaxRedemptions($command->getMaxRedemptions());
     $coupon->setStart($command->getStartDate());
     $coupon->setEnd($command->getEndDate());
     $this->couponService->create($coupon);
 }
Exemplo n.º 4
0
 public function handle(DeleteCouponCommand $command)
 {
     $coupon = $this->couponService->findOneById($command->getCouponId());
     $this->couponService->delete($coupon);
 }
Exemplo n.º 5
0
 public function handle(GetCouponQuery $query)
 {
     $coupon = $this->couponService->findOneById($query->getRequest()->getCouponId());
     $query->getResponse()->setCouponDTOBuilder($this->dtoBuilderFactory->getCouponDTOBuilder($coupon));
 }