コード例 #1
0
        /// <summary>
        /// Update based upon user
        /// </summary>
        /// <returns></returns>
        public async Task <IActionResult> OnPostUpdate()
        {
            Cart = await _cart.GetCart(User.Identity.Name);

            Product = await _product.GetProduct(ProductId);

            CartItem = await _cartItem.GetCartItem(ProductId, CartId);

            if (CartItem == null)
            {
                IsAvailable = true;
                return(Page());
            }
            if (Quantity <= Product.Quantity && Quantity > 0)
            {
                await _cartItem.UpdateCartQuantityAndPrice(CartItem.Product, CartItem.Cart, Quantity);

                return(new RedirectToPageResult("/Categories/Index"));
            }
            if (Quantity > Product.Quantity || Quantity <= 0)
            {
                IsAvailable = true;
                return(Page());
            }
            return(Page());
        }