private static Expression <Func <Doctor, bool> > ApplyFiliter(DoctorSearch doctorSearch) { return (d => (!doctorSearch.Categories.Any() || doctorSearch.Categories.Contains(d.CategoryId)) && (!doctorSearch.Countries.Any() || doctorSearch.Countries.Contains(d.Country)) && (!doctorSearch.Cities.Any() || doctorSearch.Cities.Contains(d.City)) && (string.IsNullOrEmpty(doctorSearch.Name) || d.Name.ToLower().Contains(doctorSearch.Name.ToLower()))); }
public IActionResult Get(string textBoxSearch, DoctorSearch doctorSearch) { if (doctorSearch == DoctorSearch.All) { return(Ok(_doctorService.GetAll())); } else if (doctorSearch == DoctorSearch.ByExaminationRoom) { if (Int32.TryParse(textBoxSearch, out int id)) { return(Ok(_doctorService.GetDoctorByExaminationRoom(id))); } else { return(Ok()); } } else { return(Ok()); } }
public async Task <IActionResult> Index(DoctorSearch doctorSearch) { var doctors = await _doctorRepository.GetDoctorsAsync(doctorSearch); return(View(new DoctorViewModel(doctors, doctorSearch))); }
public DoctorViewModel(IEnumerable <Doctor> doctors, DoctorSearch doctorSearch) { this.Doctors = doctors; this.DoctorSearch = doctorSearch; }
public async Task <IEnumerable <Doctor> > GetDoctorsAsync(DoctorSearch doctorSearch) { return(await GetAll(ApplyFiliter(doctorSearch)).Include(d => d.Category).OrderByDescending(o => o.Id).ToListAsync()); }