public async Task <int> RemoveFromCart(Product product)
        {
            var shoppingCartItem = await
                                   _ctx.CartItems.SingleOrDefaultAsync(
                s => s.Product.Id == product.Id &&
                s.CartId == _session.OnGet());

            var localAmount = 0;

            if (shoppingCartItem != null)
            {
                if (shoppingCartItem.Quantity > 1)
                {
                    shoppingCartItem.Quantity--;
                    localAmount = shoppingCartItem.Quantity;
                }
                else
                {
                    _ctx.CartItems.Remove(shoppingCartItem);
                }
            }
            await _ctx.SaveChangesAsync();

            return(localAmount);
        }
 public ShoppingCartRepository(ApplicationDb ctx, ISessionSettings session)
 {
     _ctx           = ctx;
     _session       = session;
     ShoppingCartId = _session.OnGet();
 }