コード例 #1
0
 public void Apply(long orderId, long customerId, Product product)
 {
     if (product.GetType() == typeof(PhysicalProduct))
     {
         _shippingSlipGenerator.Generate(orderId, customerId, (PhysicalProduct)product);
     }
 }
コード例 #2
0
        public PurchaseOrderProcessResult Process(PurchaseOrder purchaseOrder)
        {
            var memberships = purchaseOrder.Items
                              .Where(item => item is Membership)
                              .Cast <Membership>();

            string shippingSlipUrl;

            foreach (var membership in memberships)
            {
                _customerRepository.ActivateMembership(purchaseOrder.CustomerId, membership);
            }

            if (purchaseOrder.Items.Any(item => item is Product))
            {
                shippingSlipUrl = _shippingSlipGenerator.Generate(purchaseOrder.Items);
            }
            else
            {
                shippingSlipUrl = null;
            }

            return(new PurchaseOrderProcessResult
            {
                ShippingSlipUrl = shippingSlipUrl
            });
        }
コード例 #3
0
        public long?Process()
        {
            if (LineItems == null || !LineItems.Any())
            {
                throw new ArgumentNullException(nameof(LineItems));
            }

            var memberships = LineItems.Where(_ => _ is Membership);

            foreach (var membership in memberships)
            {
                var membershipDAO = _mapper.Map <MembershipDAO>(membership);
                _customerRepository.ActivateMembership(Customer.Id, membershipDAO);
            }

            var physicalProducts = LineItems.Where(_ => _ is PhysicalProduct).Cast <PhysicalProduct>().ToList();

            if (physicalProducts.Any())
            {
                return(_shippingSlipGenerator.Generate(physicalProducts));
            }

            return(null);
        }