public void Add(Goods goods, int amount) { if (goods.IsEighteen && CurrentUser.Age < 18) { throw new ArgumentException("You are not old enough to order alcohol."); } if (goods == null) { throw new ArgumentNullException("Product is null.", nameof(goods)); } if (amount <= 0) { throw new ArgumentException("Amount should be positive.", nameof(amount)); } CurrentOrder.AddToBasket(goods.Id, amount); Goods temp = null; foreach (var item in CurrentBasket) { if (item.Key.Id == goods.Id) { temp = item.Key; } } if (temp == null) { CurrentBasket.Add(goods, amount); } else { CurrentBasket[temp] += amount; } }