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)); }
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)); }