public static void DelAllItem(this List <OrderClass> Order, string Code) { OrderClass o = Order.Find(x => x.Code == Code); if (o != null) { Order.Remove(o); } }
public static void MinusItem(this List <OrderClass> Order, string Code) { OrderClass o = Order.Find(x => x.Code == Code); if (o != null) { o.Quantity -= 1; if (o.Quantity <= 0) { Order.Remove(o); } } }
public static void AddItem(this List <OrderClass> Order, string Code, string Title, decimal Price) { OrderClass o = Order.Find(x => x.Code == Code); if (o != null) { o.Quantity += 1; } else { Order.Add(new OrderClass { Code = Code, Title = Title, Quantity = 1, Price = Price }); } }