Example #1
0
 //添加
 public void AddItem(Product product, int quantity)
 {
     CartLine line = lineCollection.Where(p => p.Product.Id == product.Id).FirstOrDefault();
     if (line == null)
     {
         lineCollection.Add(new CartLine(){Product = product, Quantity = quantity});
     }
     else
     {
         line.Quantity += quantity;
     }
 }
Example #2
0
 //移除
 public void RemoveLine(Product product)
 {
     lineCollection.RemoveAll(p => p.Product.Id == product.Id);
 }