public ActionResult GetPatientListByFilter(DataTablesRequest dataTablesRequest, PatientFilter patient) { Service serv = new Service(); int totalRecordsNumber; var model = serv.FindPatiets(dataTablesRequest, patient, out totalRecordsNumber); return new DataTablesResult(dataTablesRequest.sEcho, totalRecordsNumber, totalRecordsNumber, model); }
public IEnumerable<PatientTableView> FindPatiets(DataTablesRequest dataTablesRequest, PatientFilter patient, out int totalRecordsNumber) { IQueryable<Patient> query = db.Patients.AsQueryable<Patient>(); if (!String.IsNullOrEmpty(patient.FirstName)) { query = query.Where(x => x.FirstName.Contains(patient.FirstName)); } if (!String.IsNullOrEmpty(patient.LastName)) { query = query.Where(x => x.LastName.Contains(patient.LastName)); } if (patient.Pesel.HasValue) { query = query.Where(x => x.Pesel == patient.Pesel); } totalRecordsNumber = query.Count(); query = query.OrderBy(x => x.Id).Skip(dataTablesRequest.iDisplayStart).Take(dataTablesRequest.iDisplayLength); var patientDBList = query.ToList<Patient>(); var patientTableList = new List<PatientTableView>(); foreach (var pat in patientDBList) { PatientTableView p = new PatientTableView() { City = pat.City.CityName, FirstName = pat.FirstName, Id = pat.Id, LastName = pat.LastName, Pesel = pat.Pesel.ToString() }; patientTableList.Add(p); } return patientTableList; }
public ActionResult SearchPatient() { var model = new PatientFilter(); return PartialView(model); }