Exemplo n.º 1
0
        public async Task <IActionResult> OnGet(int productId)
        {
            Product = await repository.GetProductAsync(productId);

            if (Product == null)
            {
                return(RedirectToPage("./NotFound"));
            }

            return(Page());
        }
Exemplo n.º 2
0
        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));
            }
        }
Exemplo n.º 3
0
        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());
        }
Exemplo n.º 4
0
        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());
        }