public Decimal AddItem(Product product, Decimal quantity) { if (cardItems.ContainsKey(product)) { if (cardItems[product] + quantity > 0) { cardItems[product] += quantity; } else { throw new Exception(product.Name +" quantity should be greater than zero."); } } else { if (quantity > 0) { cardItems.Add(product, quantity); } else { throw new Exception(product.Name + " quantity should be greater than zero."); } } return cardItems[product]; }
public void RemoveItem(Product product) { cardItems.Remove(product); }