public ActionResult SearchBest(int page = 1, string name = null, int?speciality = null, string search = null) { if (!string.IsNullOrEmpty(name)) { name = name.Trim(); //if (name.IndexOf(' ') != -1) //{ // name = name.Replace(" ", "|"); //} } if (!string.IsNullOrEmpty(search)) { search = search.Trim(); //if (search.IndexOf(' ') != -1) //{ // search = search.Replace(" ", "|"); //} } var doctors = this.doctorService.SearchDoctors(name, speciality, search); var docmodel = AutoMapper.Mapper.Map <IEnumerable <DoctorViewModel> >(doctors); var selectedAll = new SelectListItem { Text = "All", Value = "" }; var specialitiesList = this.doctorService .GetSpecialities() .Select(s => new SelectListItem { Text = s.Name, Value = s.Id.ToString() }) .ToList(); specialitiesList.Insert(0, selectedAll); var citiesList = this.cityService .GetCities() .Select(c => new SelectListItem { Text = c.CityName, Value = c.CityId.ToString() }) .ToList(); citiesList.Insert(0, selectedAll); var model = new FilterDoctorsViewModel() { Doctors = new PagedList <DoctorViewModel>(docmodel, page, ItemsPerPage), Cities = citiesList, Specialities = specialitiesList }; return(View(model)); }
public ActionResult All(int page = 1, int?city = null, int?speciality = null) { ViewBag.CityId = city; ViewBag.SpecialityId = speciality; var docmodel = this._doctorService .SearchDoctors(city, speciality); var doctors = AutoMapper.Mapper.Map <IEnumerable <DoctorViewModel> >(docmodel); var citiesList = this.cityService .GetCities() .Select(c => new SelectListItem { Text = c.CityName, Value = c.CityId.ToString() }) .ToList(); var selectedAll = new SelectListItem { Text = "All", Value = "" }; citiesList.Insert(0, selectedAll); var specialitiesList = this._doctorService .GetSpecialities() .Select(s => new SelectListItem { Text = s.Name, Value = s.Id.ToString() }) .ToList(); specialitiesList.Insert(0, selectedAll); var model = new FilterDoctorsViewModel() { Doctors = new PagedList <DoctorViewModel>(doctors, page, ItemsPerPage), Cities = citiesList, Specialities = specialitiesList }; return(View(model)); }