public ActionResult Index(IndexVM model) { model.Pager = model.Pager ?? new PagerVM(); model.Pager.Page = model.Pager.Page <= 0 ? 1 : model.Pager.Page; model.Pager.ItemsPerPage = model.Pager.ItemsPerPage <= 0 ? 10 : model.Pager.ItemsPerPage; model.Filter = model.Filter ?? new FilterVM(); model.Filter.PatientId = model.PatientId; model.Filter.DoctorId = model.DoctorId; model.Filter.AppointmentDate = model.AppointmentDate; Expression <Func <Appointment, bool> > filter = model.Filter.GenerateFilter(); AppointmentRepository repo = new AppointmentRepository(); model.items = repo.GetAll(filter, model.Pager.Page, model.Pager.ItemsPerPage); model.Pager.PagesCount = (int)Math.Ceiling(repo.Count(filter) / (double)(model.Pager.ItemsPerPage)); PatientRepository patientsRepo = new PatientRepository(); //model.PatientOne = patientsRepo.GetById(model.PatientId); model.PatientList = patientRepo.GetAll(); DoctorRepository doctorsRepo = new DoctorRepository(); //model.DoctorOne = doctorsRepo.GetById(model.DoctorId); model.DoctorList = doctorRepo.GetAll(); return(View(model)); }