public ActionResult Advanced( string q, List <int> requireFlags, List <int> blockFlags, List <int> allowFlags, List <int> platforms, List <int> genres, int page = 1 ) { requireFlags = requireFlags?.Where(x => x >= 0).ToList() ?? new List <int>(); blockFlags = blockFlags?.Where(x => x >= 0).ToList() ?? new List <int>(); allowFlags = allowFlags?.Where(x => x >= 0).ToList() ?? new List <int>(); platforms = platforms?.Where(x => x >= 0).ToList() ?? new List <int>(); genres = genres?.Where(x => x >= 0).ToList() ?? new List <int>(); // Determine if we're showing results or displaying the form if (string.IsNullOrEmpty(q) && !requireFlags.Any() && !blockFlags.Any() && !allowFlags.Any() && !platforms.Any() && !genres.Any()) { var viewModelGenres = GameHelpers.GetGenres(); var viewModelPlatforms = GameHelpers.GetPlatforms(); return(View(new AdvancedSearchViewModel { Genres = viewModelGenres, Platforms = viewModelPlatforms })); } var results = SearchHelpers.AdvancedSearch(q, requireFlags, blockFlags, allowFlags, platforms, genres); var games = results.Skip((page - 1) * PageLimit).Take(PageLimit).ToList(); var retval = new SearchResult { Page = page, Results = games, Query = q, AllowFlags = allowFlags, BlockFlags = blockFlags, RequireFlags = requireFlags, Genres = genres, Platforms = platforms, Type = SearchType.Advanced }; return(View("Search", retval)); }