Beispiel #1
0
        public void AddBasket(long goodId, decimal count)
        {
            var good = GoodsView.Where(s => s.id == goodId).FirstOrDefault();
            var item = new GoodSell
            {
                goodId       = good.id,
                goodName     = good.name,
                priceOne     = good.price,
                goodTypeName = good.typeName,
                count        = count,
                summ         = good.price * count,
                oneType      = good.info
            };

            basket = basket ?? new List <GoodSell>();
            var goodInBasket = basket.Where(s => s.goodId == goodId).FirstOrDefault();

            if (goodInBasket != null)
            {
                goodInBasket.count += item.count;
                goodInBasket.summ  += item.summ;
            }
            else
            {
                basket.Add(item);
            }

            if (basketChange != null)
            {
                basketChange(this, EventArgs.Empty);
            }
        }