public void AddItem(AddToBasketViewModel item)
        {
            var existingItem = _items.SingleOrDefault(model => model.Id == item.Id);

            if (existingItem == null)
            {
                _items.Add(item);
                return;
            }

            existingItem.Merge(item);
        }
예제 #2
0
        public void Merge(AddToBasketViewModel item)
        {
            if (item.Id != Id)
            {
                throw new InvalidOperationException();
            }
            if (item.Description != Description)
            {
                throw new InvalidOperationException();
            }

            Quantity += item.Quantity;
        }