public ActionResult Index(string searchString, string selectedLocation) { OpenJobs[] All_Jobs = js.Get_Job_Posting_List(); IEnumerable <OpenJobs> jobList = All_Jobs.ToList(); var allUniqueLocations = jobList.Select(x => x.Job_Location).Distinct().ToList(); if (!String.IsNullOrEmpty(searchString)) { if (selectedLocation != "All Locations") { jobList = jobList.Where( x => x.Job_Location.Contains(selectedLocation) && x.Job_Title.Contains(searchString)); } if (selectedLocation == "All Locations") { jobList = jobList.Where(x => x.Job_Title.Contains(searchString)); } //jobList = jobList.Where(s => s.Job_Title.Contains(searchString) // || s.Job_Location.Contains(searchString)); } else { if (selectedLocation == null) { selectedLocation = "All Locations"; } if (selectedLocation != "All Locations") { jobList = jobList.Where(x => x.Job_Location.Contains(selectedLocation)); } } JobPostingViewModel finalModel = new JobPostingViewModel { AllJobs = jobList, Locations = allUniqueLocations }; return(View(finalModel)); }