コード例 #1
0
        public void MinusItem(ref bool isOne, SportsProduct product, int quantity)
        {
            CartLine line = lineCollection
                            .Where(p => p.Product.ProductID == product.ProductID)
                            .FirstOrDefault();

            if (line.Quantity > 1)
            {
                line.Quantity -= quantity;
            }
            else
            {
                isOne = true;
            }
        }
コード例 #2
0
        public void AddItem(SportsProduct product, int quantity)
        {
            CartLine line = lineCollection
                            .Where(p => p.Product.ProductID == product.ProductID)
                            .FirstOrDefault();

            if (line == null)
            {
                lineCollection.Add(new CartLine {
                    Product = product, Quantity = quantity
                });
            }
            else
            {
                line.Quantity += quantity;
            }
        }
コード例 #3
0
 public void RemoveLine(SportsProduct product)
 {
     lineCollection.RemoveAll(l => l.Product.ProductID == product.ProductID);
 }