コード例 #1
0
        //点击数量+号或点击数量-号或自己输入一个值
        public void ChangeItmeQty(ShoppingCartLine cartLine, int qty)
        {
            if (qty == 0)
            {
                RemoveItem(cartLine);
            }

            cartLine.Qty = qty;
        }
コード例 #2
0
        //添加
        public void AddGoods(Goods.Goods goods, int quantity)
        {
            ShoppingCartLine line = ShoppingCartLines.FirstOrDefault(p => p.Goods.Id == goods.Id);

            if (line == null)
            {
                ShoppingCartLines.Add(new ShoppingCartLine()
                {
                    Goods          = goods,
                    Qty            = quantity,
                    ShoppingCartId = this.Id
                });
            }
            else
            {
                line.Qty += quantity;
            }
        }
コード例 #3
0
 //移除
 public void RemoveItem(ShoppingCartLine cartLine)
 {
     ShoppingCartLines.Remove(cartLine);
 }