예제 #1
0
 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;
     }
 }
예제 #2
0
 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&lt;T&gt; 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;
 }
예제 #5
0
 public void RemoveItem(FOOD food)
 {
     _cartItems.RemoveAll(p => p.Food.ID == food.ID);
 }