Ejemplo n.º 1
0
        public IActionResult Index(int?page, string sortBy, string searchTerm, string searchFilter)
        {
            var recipes = _recipeData.GetRecipeBy(searchFilter, searchTerm).ToList();


            if (!page.HasValue)
            {
                page = 1;
            }


            if (string.IsNullOrWhiteSpace(sortBy))
            {
                sortBy = "name";
            }

            var viewModel = new RecipeListViewModel
            {
                Recipes = recipes,
                Page    = page.Value,
                SortBy  = sortBy
            };

            return(View(viewModel));
        }