public static void Handle(ProductItemRemovedFromShoppingCart @event, ShoppingCartDetails view)
    {
        var productItem         = @event.ProductItem;
        var existingProductItem = view.ProductItems
                                  .Single(x => x.ProductId == @event.ProductItem.ProductId);

        if (existingProductItem.Quantity == productItem.Quantity)
        {
            view.ProductItems.Remove(existingProductItem);
        }
        else
        {
            existingProductItem.Quantity -= productItem.Quantity;
        }

        view.Version++;
    }
Exemple #2
0
 public static void Handle(ProductItemRemovedFromShoppingCart @event, ShoppingCartShortInfo view)
 {
     view.TotalItemsCount -= @event.ProductItem.Quantity;
     view.TotalPrice      -= @event.ProductItem.TotalPrice;
     view.Version++;
 }