public ActionResult EditHospitals(int id) { var doctor = _doctorRepository.Get(id); var viewModel = new DoctorHospitalsViewModel() { DoctorId = doctor.Id, FullName = doctor.FullName, Hospitals = doctor.Hospitals }; // Extend the Hospitals to a total of 6 for data entry while (viewModel.Hospitals.Count < 6) { viewModel.Hospitals.Add(new DoctorHospital()); } if (Session["HospitalItems"] == null) { var items = _hospitalRepository.Search("") .Select(s => new { Text = s.HospitalName, Value = s.Id }) .ToList(); Session["HospitalItems"] = items; } ViewBag.HospitalItems = Session["HospitalItems"]; return(View(viewModel)); }
public PartialViewResult Search(string search) { var model = _hospitalRepository.Search(search); return(PartialView(model)); }