public CheckOutResultDto CheckOut(Guid customerId)
        {
            CheckOutResultDto checkOutResultDto = new CheckOutResultDto();

            Cart cart = this.cartRepository.FindOne(new CustomerCartSpec(customerId));

            this.validateCart(customerId, cart);

            Customer customer = this.customerRepository.FindById(cart.CustomerId);

            Nullable <CheckOutIssue> checkOutIssue =
                this.checkoutDomainService.CanCheckOut(customer, cart);

            if (!checkOutIssue.HasValue)
            {
                Purchase purchase = this.checkoutDomainService.Checkout(customer, cart);
                checkOutResultDto = Mapper.Map <Purchase, CheckOutResultDto>(purchase);
                this.unitOfWork.Commit();
            }
            else
            {
                checkOutResultDto.CheckOutIssue = checkOutIssue;
            }

            return(checkOutResultDto);
        }
        public CheckOutResultDto CheckOut(Guid customerId)
        {
            CheckOutResultDto checkOutResultDto = new CheckOutResultDto();
            Customer customer = this.repositoryCustomer.FindById(customerId);
            this.validateCustomer(customerId, customer);

            checkOutResultDto.CheckOutIssue = customer.Cart.IsCheckOutReady();

            if (!checkOutResultDto.CheckOutIssue.HasValue)
            {
                Purchase purchase = customer.Cart.Checkout();
                checkOutResultDto = Mapper.Map<Purchase, CheckOutResultDto>(purchase);
                this.unitOfWork.Commit();
            }

            return checkOutResultDto;
        }
Exemple #3
0
        public CheckOutResultDto CheckOut(Guid customerId)
        {
            CheckOutResultDto checkOutResultDto = new CheckOutResultDto();
            Customer          customer          = this.repositoryCustomer.FindById(customerId);

            this.validateCustomer(customerId, customer);

            checkOutResultDto.CheckOutIssue = customer.Cart.IsCheckOutReady();

            if (!checkOutResultDto.CheckOutIssue.HasValue)
            {
                Purchase purchase = customer.Cart.Checkout();
                checkOutResultDto = Mapper.Map <Purchase, CheckOutResultDto>(purchase);
                this.unitOfWork.Commit();
            }

            return(checkOutResultDto);
        }