コード例 #1
0
        public void AddToBasket(int customerId, int productId)
        {
            var currentBasket = _basket.GetBasket(customerId);

            if (currentBasket == null)
            {
                currentBasket = new BasketWithGoods
                {
                    CustomerId = customerId,
                    ProductIds = new List <int>(productId)
                };
                _basket.AddToBasket(currentBasket);
            }
            else
            {
                currentBasket.Quantity = productId;
                //add number of elements to the list
            }
            //productId is not added to the list of all prods!
            currentBasket.ProductIds.Add(productId);
        }
コード例 #2
0
 public void AddToBasket(BasketWithGoods basket)
 {
     _basket.Add(basket);
 }