public IEnumerable <Doctor> GetFilteredDoctors(DoctorFilter filter) { ISpecification <Doctor> specification = new DoctorSpecificationConverter(filter).GetSpecification(); var doctors = Find(specification); Bind(doctors); return(doctors); }
public IActionResult Doctors(DoctorFilter filter) { ViewData["CurPage"] = "1"; IEnumerable <Doctors> doctors = null; if (filter.doctorName != null) { filter.currentPage = 1; ViewData["DoctorFilter"] = filter.doctorName; doctors = _repository.GetDoctorByName(filter.doctorName); } else { doctors = _repository.GetAllDoctors(); } if (doctors.Count() % 6 != 0) { ViewBag.LastPageNumber = ((doctors.Count() / 6) + 1).ToString(); } else { ViewBag.LastPageNumber = (doctors.Count() / 6).ToString(); } List <Doctors> x; if (filter.currentPage != 1) { x = doctors.Skip((filter.currentPage - 1) * 6).Take(6).ToList(); ViewBag.CurPageNumber = filter.currentPage.ToString(); ViewBag.NextPageNumber = (filter.currentPage + 1).ToString(); ViewBag.PreviousPageNumber = (filter.currentPage - 1).ToString(); } else { x = doctors.Take(6).ToList(); ViewBag.CurPageNumber = "1"; ViewBag.NextPageNumber = 2; } return(View(x)); }
public IEnumerable <Doctor> GetFilteredDoctors(DoctorFilter filter) { ISpecification <Doctor> specification = new DoctorSpecificationConverter(filter).GetSpecification(); var doctors = Find(specification); var eagerDocs = GetAllEager(); IEnumerable <Doctor> result = new List <Doctor>(); foreach (var doctor in doctors) { foreach (var eagerDoc in eagerDocs) { if (doctor.GetId() == eagerDoc.GetId()) { result.Append(eagerDoc); } } } return(result); }
public IEnumerable <Doctor> GetFilteredDoctors(DoctorFilter filter) => _doctorService.GetFilteredDoctors(filter);
public DoctorSpecificationConverter(DoctorFilter filter) { _filter = filter; }
public ActionResult Index(string sortOrder, DoctorFilter filter = null, string query = null) { IEnumerable <Doctor> doctors = doctors = _doctorRepository.GetAllDoctors(); ViewBag.NameSortParm = sortOrder == "Name" ? "name_desc" : "Name"; ViewBag.DegreeSortParm = sortOrder == "Degree" ? "degree_desc" : "Degree"; ViewBag.IdSortParm = sortOrder == "Id" ? "id_desc" : "Id"; if (!String.IsNullOrWhiteSpace(query)) { doctors = doctors.Where(g => g.FullName.Contains(query)); } if (filter.Speciality.HasValue) { doctors = _doctorRepository.FilterDoctorsBySpeciality(filter.Speciality); } if (filter.Degree != null) { doctors = doctors.Where(d => d.Degree == filter.Degree); } switch (sortOrder) { case "name_desc": doctors = doctors.OrderByDescending(d => d.FullName); break; case "Name": doctors = doctors.OrderBy(d => d.FullName); break; case "degree_desc": doctors = doctors.OrderByDescending(d => d.Degree); break; case "Degree": doctors = doctors.OrderBy(d => d.Degree);; break; case "id_desc": doctors = doctors.OrderByDescending(d => d.DoctorId); break; case "Id": doctors = doctors.OrderBy(d => d.DoctorId); break; default: break; } var viewModel = new DoctorListViewModel { Doctors = doctors, Specialities = _specialityRepository.GetSpecialities(), Degree = _doctorRepository.SelectDegrees(), SearchTerm = query }; return(View(viewModel)); }