Esempio n. 1
0
        public void AddProduct(Product product, Quantity quantity)
        {
            if (product == null)
                throw new InvalidProductInstanceException();

            if (quantity == null)
                throw new InvalidQuantityInstanceException();

            Apply(new ProductAddedToCart(CustomerId, product.Id, quantity, product.Price));
        }
Esempio n. 2
0
        public void RemoveProduct(Product product)
        {
            if (product == null)
                throw new InvalidProductInstanceException();

            if (!_items.Any(i => i.ProductId == product.Id))
                throw new ProductNotFoundInCartException();

            Apply(new ProductRemovedFromCart(CustomerId, product.Id));
        }