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)); }
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)); }