コード例 #1
0
        public void Handle(ItemsRemovedEvent itemsRemovedEvent)
        {
            if (itemsRemovedEvent == null)
            {
                throw new ArgumentNullException(nameof(itemsRemovedEvent));
            }

            VerifyProductSkuMatchesInput(itemsRemovedEvent.ProductSku);

            Quantity = (Quantity - itemsRemovedEvent.Quantity) <= 0
                ? 0
                : Quantity - itemsRemovedEvent.Quantity;
        }
コード例 #2
0
        private void Handle(ItemsRemovedEvent itemsRemovedEvent)
        {
            var existingItem = FindExistingCartItem(itemsRemovedEvent.ProductSku);

            if (existingItem == null)
            {
                throw new CartException($"Product \"{itemsRemovedEvent.ProductSku}\" " +
                                        $"does not exist in the cart ({Id}).");
            }
            else
            {
                existingItem.Handle(itemsRemovedEvent);
            }

            PurgeZeroQuantityProducts();
        }