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()); } }
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); }
public async Task OnGetAsync(int productId, [FromServices] GetProduct getProduct) { Product = await getProduct.DoAsync(productId); }