public ShoppingCartCookie(ProductCookie productCookie) { Products = new List <ProductCookie>() { productCookie }; }
public void AddProduct(ProductCookie productCookie) { if (productCookie == null) { throw new ArgumentNullException(nameof(productCookie)); } if (Products.Any(p => p.InventoryId == productCookie.InventoryId)) { var product = Products.FirstOrDefault(p => p.InventoryId == productCookie.InventoryId); if (product != null) { product.IncreaseAmount(); } else { throw new Exception("Something went wrong inside appending a cookie"); } } else { Products.Add(productCookie); } }