Пример #1
0
        public static CartProduct Create(Customer customer, Cart cart, Product product, int quantity,
                                         TaxService taxService)
        {
            if (cart == null)
            {
                throw new ArgumentNullException("cart");
            }

            if (product == null)
            {
                throw new ArgumentNullException("product");
            }

            var cartProduct = new CartProduct
            {
                CustomerId = customer.Id,
                CartId     = cart.Id,
                ProductId  = product.Id,
                Quantity   = quantity,
                Created    = DateTime.Now,
                Cost       = product.Cost,
                Tax        = taxService.Calculate(customer, product)
            };

            return(cartProduct);
        }
Пример #2
0
        public virtual void Add(CartProduct cartProduct)
        {
            if (cartProduct == null)
            {
                throw new ArgumentNullException();
            }

            DomainEvents.Raise(new ProductAddedCart {
                CartProduct = cartProduct
            });

            _cartProducts.Add(cartProduct);
        }