public ActionResult Search(string key) { if (!string.IsNullOrEmpty(key)) { IEnumerable <Volunteer> results = _volunteerRepository.Search(key); if (results.Any()) { ViewData.Model = results; return(View("SearchResults")); } else { TempData["error"] = "Volunteer not Found: Please recheck your spelling."; ViewData.Model = _volunteerRepository.GetAllVolunteers(); return(View("ManageVolunteers")); } } else { TempData["error"] = "Empty String: Please try again."; ViewData.Model = _volunteerRepository.GetAllVolunteers(); return(View("ManageVolunteers")); } }
public IActionResult Search(string SearchString) { if (!String.IsNullOrEmpty(SearchString)) { ViewData.Model = _volunteerRepository.Search(SearchString); return(View("VolunteerList")); } else { ViewData.Model = _volunteerRepository.getVolunteers(); return(View("VolunteerList")); } }