public void Apply(long orderId, long customerId, Product product) { if (product.GetType() == typeof(PhysicalProduct)) { _shippingSlipGenerator.Generate(orderId, customerId, (PhysicalProduct)product); } }
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 }); }
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); }