public ActionResult Index(int?page, int?bookingId, int pageSize = 5, string patient = "") { if (Request.HttpMethod != "GET") { page = 1; } int pageNumber = (page ?? 1); if (bookingId.HasValue) { bb.EndConsultaion(bookingId.Value); } ViewData["CountPatients"] = bb.CountMethod().ToString(); ViewBag.Info = bb.Consulted(); ViewData["N_count"] = bb.NotConsulted(); //List<PatientModel> pm = pb.GetAllPatients(); var bop = bb.GetAllBookings().Where(x => x.Status == 0 && Convert.ToDateTime(x.start_date).Date.Day == DateTime.Now.Day && Convert.ToDateTime(x.start_date).Date.Month == DateTime.Now.Month && Convert.ToDateTime(x.start_date).Date.Year == DateTime.Now.Year).ToList(); List <bookingPatient> bp = bop.OrderBy(x => x.time).Where(x => x.FullName.ToLower().Contains(patient.ToLower()) || x.Telephone.ToLower().Contains(patient.ToLower()) || x.Email.ToLower().Contains(patient.ToLower()) || patient == null).ToList(); PagedList <bookingPatient> model = new PagedList <bookingPatient>(bp, pageNumber, pageSize); return(View("Index", bp.ToPagedList(pageNumber, pageSize))); }