public async Task <IActionResult> OnGet(int productId) { Product = await repository.GetProductAsync(productId); if (Product == null) { return(RedirectToPage("./NotFound")); } return(Page()); }
public async Task <ActionResult <ProductDto> > GetProduct(int id) { var product = await repository.GetProductAsync(id); if (product == null) { return(NotFound()); } else { return(mapper.Map <ProductDto>(product)); } }
public async Task <IActionResult> OnGet(int?productId) { Categories = htmlHelper.GetEnumSelectList <CategoryType>(); if (productId.HasValue) { Product = await repository.GetProductAsync(productId.Value); if (Product == null) { return(RedirectToPage("./NotFound")); } } else { Product = new Product(); } return(Page()); }
public async Task <IActionResult> OnGet(int productId) { Product = await repository.GetProductAsync(productId); if (Product == null) { return(RedirectToPage("./NotFound")); } var recipes = await repository.GetAllRecipesAsync(); var recipesWithThisProduct = recipes.Where(r => r.Ingredients.Any(p => p.Product.Name == Product.Name)); Recipes = mapper.Map <RecipeDto[]>(recipesWithThisProduct); return(Page()); }