public ActionResult Index(string patient, int?page, int pageSize = 5) { TempData["msg"] = "false"; int pageNumber = (page ?? 1); if (string.IsNullOrEmpty(patient)) { if (ModelState.IsValid) { TempData["msg"] = "Emp"; return(View(b.GetAllPat(patient).ToPagedList(pageNumber, pageSize))); } else { return(View()); } } else if (b.PatientExist(patient) == 0) { TempData["msg"] = "all"; if (b.GetAllPat(patient).Count == 0) { TempData["msg"] = "true"; } return(View(b.GetAllPat(patient).ToPagedList(pageNumber, pageSize))); } else if (b.PatientExist(patient) >= 1) { return(RedirectToAction("Details", new { id = b.PatientExist(patient) })); } else { TempData["msg"] = "true"; return(View(b.GetAllPat(patient).ToPagedList(pageNumber, pageSize))); } }