Beispiel #1
0
        public async Task <IActionResult> Recipe([FromServices] IRecipeService recipeService, [FromQuery] string search)
        {
            var viewModel = new ListRecipeViewModel();

            if (string.IsNullOrWhiteSpace(search))
            {
                viewModel.RecipeList = await recipeService.GetAllAsync();
            }
            else
            {
                viewModel.RecipeList = await recipeService.GetAllContainsNameAsync(search);

                viewModel.Search = search;
            }

            return(View(viewModel));
        }
Beispiel #2
0
        public async Task <IActionResult> List([FromQuery] string search)
        {
            var user = await _userManager.GetUserAsync(User);

            var viewModel = new ListRecipeViewModel();

            if (string.IsNullOrWhiteSpace(search))
            {
                viewModel.RecipeList = await _recipeService.RecipeUserListAsync(user);
            }
            else
            {
                viewModel.RecipeList = await _recipeService.GetAllContainsNameAsync(search, user);

                viewModel.Search = search;
            }

            return(View(viewModel));
        }