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; }
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(); }