Example #1
0
        public async Task <IActionResult> OnGet(string name, [FromServices] GetProduct getProduct)
        {
            Product = await getProduct.DoAsync(int.Parse(name));

            if (Product == null)
            {
                return(RedirectToPage("Index"));
            }
            else
            {
                return(Page());
            }
        }
Example #2
0
        public async Task <int> GeStocks(int productId, int stockId, [FromServices] GetProduct getProduct)
        {
            var product = await getProduct.DoAsync(productId);

            var stock = product.Stock.FirstOrDefault(x => x.Id == stockId);

            if (stock == null)
            {
                return(0);
            }

            return(stock.Qty);
        }
Example #3
0
 public async Task OnGetAsync(int productId, [FromServices] GetProduct getProduct)
 {
     Product = await getProduct.DoAsync(productId);
 }