public ActionResult Index(string selectedLetter) { var model = new AlphabeticalPagingViewModel { SelectedLetter = selectedLetter }; model.FirstLetters = this.ingredients.GetFirstLetters(); if (string.IsNullOrEmpty(selectedLetter) || selectedLetter == "All") { model.Ingredients = this.ingredients.GetAll() .OrderBy(p => p.Name) .To <IngredientViewModel>() .ToList(); return(this.View(model)); } else { model.Ingredients = this.ingredients.GetIngredientsWithCommonLetter(selectedLetter.ToLower()) .To <IngredientViewModel>() .ToList(); } return(this.View(model)); }
public async Task <IActionResult> All(string searchString, string currentFilter, string selectedLetter, int?pageNumber) { this.ViewData["Current"] = nameof(this.All); if (searchString != null) { pageNumber = 1; } else { searchString = currentFilter; } this.ViewData["CurrentSearchFilter"] = searchString; var movies = this.moviesService .GetAllMoviesByFilterAsQueryeable <MovieDetailsViewModel>(selectedLetter); if (!string.IsNullOrEmpty(searchString)) { movies = movies.Where(m => m.Name.ToLower().Contains(searchString.ToLower())); } var moviesPaginated = await PaginatedList <MovieDetailsViewModel> .CreateAsync(movies, pageNumber ?? 1, PageSize); var alphabeticalPagingViewModel = new AlphabeticalPagingViewModel { SelectedLetter = selectedLetter, }; var viewModel = new MoviesListingViewModel { Movies = moviesPaginated, AlphabeticalPagingViewModel = alphabeticalPagingViewModel, }; return(this.View(viewModel)); }
public ActionResult Index(string selectedLetter) { var model = new AlphabeticalPagingViewModel { SelectedLetter = selectedLetter }; model.FirstLetters = this.ingredients.GetFirstLetters(); if (string.IsNullOrEmpty(selectedLetter) || selectedLetter == "All") { model.Ingredients = this.ingredients.GetAll() .OrderBy(p => p.Name) .To<IngredientViewModel>() .ToList(); return this.View(model); } else { model.Ingredients = this.ingredients.GetIngredientsWithCommonLetter(selectedLetter.ToLower()) .To<IngredientViewModel>() .ToList(); } return this.View(model); }