Beispiel #1
0
        public void UpdateItem(PhongKhachSan phong, int quantity)
        {
            CartItem item = _ListCart.Where(p => p.Phong.ID == phong.ID).FirstOrDefault();

            if (item != null)
            {
                if (quantity > 0)
                {
                    item.Quantity = quantity;
                }
                else
                {
                    _ListCart.RemoveAll(i => i.Phong.ID == phong.ID);
                }
            }
        }
Beispiel #2
0
        public void AddItem(PhongKhachSan phong, int quantity)
        {
            CartItem item = _ListCart.Where(p => p.Phong.ID == phong.ID).FirstOrDefault();

            if (item == null)
            {
                _ListCart.Add(new CartItem
                {
                    Phong    = phong,
                    Quantity = quantity
                });
            }
            else
            {
                item.Quantity += quantity;
                if (item.Quantity <= 0)
                {
                    _ListCart.RemoveAll(i => i.Phong.ID == phong.ID);
                }
            }
        }
Beispiel #3
0
 public void RemoveItem(PhongKhachSan phong)
 {
     _ListCart.RemoveAll(i => i.Phong.ID == phong.ID);
 }