public void AddItem(FOOD food, int quantity) { CartItem item = _cartItems.Where(p => p.Food.ID == food.ID).FirstOrDefault(); if (item == null) { _cartItems.Add(new CartItem(){Food = food,Quantity = quantity}); } else { item.Quantity += quantity; } }
public void UpdateQuantity(FOOD food,int quantity) { CartItem item = null; foreach (CartItem cartItem in Items) { if (cartItem.Food.ID == food.ID) { item = cartItem; break; } } item.Quantity = quantity; }
/// <summary> /// Deprecated Method for adding a new object to the FOODs EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToFOODs(FOOD fOOD) { base.AddObject("FOODs", fOOD); }
/// <summary> /// Create a new FOOD object. /// </summary> /// <param name="id">Initial value of the ID property.</param> public static FOOD CreateFOOD(global::System.Int32 id) { FOOD fOOD = new FOOD(); fOOD.ID = id; return fOOD; }
public void RemoveItem(FOOD food) { _cartItems.RemoveAll(p => p.Food.ID == food.ID); }