public void AddProduct(Product product, int quantity) { if (product == null) { throw new Exception("you cann't add an invalid item to the shopping cart!"); } if (quantity == 0) { throw new Exception("quantity should be bigger than 0 !"); } OrderItem existingItem = this.Items.FirstOrDefault(i => i.ProductID == product.ID); if (existingItem != null) { existingItem.Quantity++; } else { base.Add(OrderFactory.CreateOrderItem(product, quantity)); } }