public function handle(UpdateCouponCommand $command) { $couponDTO = $command->getCouponDTO(); $coupon = $this->couponService->findOneById($couponDTO->id); CouponDTOBuilder::setFromDTO($coupon, $couponDTO); $this->couponService->update($coupon); }
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)); } }
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); }
public function handle(DeleteCouponCommand $command) { $coupon = $this->couponService->findOneById($command->getCouponId()); $this->couponService->delete($coupon); }
public function handle(GetCouponQuery $query) { $coupon = $this->couponService->findOneById($query->getRequest()->getCouponId()); $query->getResponse()->setCouponDTOBuilder($this->dtoBuilderFactory->getCouponDTOBuilder($coupon)); }