예제 #1
0
 public void RemoveItem(Product product, int quantity)
 {
     var orderDetails = _ordersDetails.Where(od => od.ProductID == product.ID).FirstOrDefault();
     if (orderDetails != null)
     {
         if (orderDetails.Quantity <= quantity)
             _ordersDetails.RemoveAll(od => od.ProductID == product.ID);
         else
             orderDetails.Quantity -= quantity;
     }
 }
예제 #2
0
 public void AddItem(Product product, int quantity)
 {
     var orderDetails = _ordersDetails.Where(od => od.ProductID == product.ID).FirstOrDefault();
     if (orderDetails == null)
     {
         _ordersDetails.Add(new OrderDetails
         {
             ProductID = product.ID,
             Product = product,
             Quantity = quantity
         });
     }
     else
     {
         orderDetails.Quantity += quantity;
     }
 }
예제 #3
0
 public void RemoveLine(Product product)
 {
     _ordersDetails.RemoveAll(od => od.ProductID == product.ID);
 }