コード例 #1
0
        public void UpdateItem(SANPHAM sp, int quantity)
        {
            CartItem line = lineCollection
                            .Where(p => p.SANPHAM.MASP == sp.MASP)
                            .FirstOrDefault();

            if (line != null)
            {
                if (quantity > 0)
                {
                    line.Quantity = quantity;
                }
                else
                {
                    lineCollection.RemoveAll(l => l.SANPHAM.MASP == sp.MASP);
                }
            }
        }
コード例 #2
0
        public void AddItem(SANPHAM sp, int quantity)
        {
            CartItem line = lineCollection
                            .Where(p => p.SANPHAM.MASP == sp.MASP)
                            .FirstOrDefault();

            if (line == null)
            {
                lineCollection.Add(new CartItem
                {
                    SANPHAM  = sp,
                    Quantity = quantity
                });
            }
            else
            {
                line.Quantity += quantity;
            }
        }
コード例 #3
0
 public void RemoveLine(SANPHAM sp)
 {
     lineCollection.RemoveAll(l => l.SANPHAM.MASP == sp.MASP);
 }