public void Update(Product item) { throw new NotImplementedException(); }
public bool Remove(Product item) { throw new NotImplementedException(); }
public void CopyTo(Product[] array, int arrayIndex) { throw new NotImplementedException(); }
public bool Contains(Product item) { throw new NotImplementedException(); }
/// <summary> /// Verifies whether a specified product has already been added to the order /// </summary> /// <param name="product">The product to search for</param> /// <returns>True if the product is found; otherwise, false</returns> private bool ContainsProduct(Product product) { Contract.Requires<ArgumentNullException>(product!=null, "product"); var count = (from i in this._Items where i.Product.Id == product.Id select i).Count(); return count != 0; }
/// <summary> /// Adds a product to an order /// </summary> /// <param name="product">The product to add to the order</param> /// <param name="discount">The discount rate to apply</param> /// <param name="quantity">The quantity to order</param> /// <exception cref="ArgumentException">Thrown if the order already contains the product or the quantity is zero</exception> public virtual void AddProduct(Product product, float discount, short quantity) { if(ContainsProduct(product)) { throw new ArgumentException("This order already contains the specified product", "product"); } if (quantity <= 0) { throw new ArgumentException("Quantity cannot be zero or less", "quantity"); } OrderItem item = new OrderItem(); item.Product = product; item.Discount = discount; item.Quantity = quantity; item.UnitPrice = product.UnitPrice; this._Items.Add(item); }