Пример #1
0
        public async Task <IActionResult> OnPost([FromServices] AddToCart addToCart)
        {
            var stockAdded = await addToCart.ExecAsync(CartDto);

            if (stockAdded)
            {
                return(RedirectToPage("Cart"));
            }

            return(Page()); // TODO: add warning that stock is on hold
        }
Пример #2
0
        public async Task <IActionResult> AddOne(int stockId, [FromServices] AddToCart addToCart)
        {
            var cartDto = new CartDto
            {
                StockId  = stockId,
                Quantity = 1
            };

            var result = await addToCart.ExecAsync(cartDto);

            if (result)
            {
                return(Ok("Item added to cart"));
            }

            return(BadRequest("Failed to add to cart"));
        }