Example #1
0
        public async Task <IActionResult> SavedRecipes(int?pageNumber, string search)
        {
            var user = await _userService.GetUserByUsername(User.Identity.Name);

            ViewData["User"]   = user;
            ViewData["search"] = search;

            int pageSize        = 9;
            var savedRecipeList = await _recipeService.AllSavedRecipes(User.Identity.Name);

            if (!String.IsNullOrEmpty(search))
            {
                savedRecipeList = await _recipeService.SearchSavedRecipes(User.Identity.Name, search);
            }

            PaginatedList <SavedRecipe> paginatedList = await PaginatedList <SavedRecipe> .CreateAsync(savedRecipeList, pageNumber ?? 1, pageSize);

            ViewData["paginatedList"] = paginatedList;

            return(View());
        }