public ActionResult Specialite(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Medecin medecin = db.Medecins.Find(id); /*ServiceRepository serviceRepository = new ServiceRepository(); * Service service = serviceRepository.FindServiceByMedecinId(id);*/ SpecialiteRepository specialiteRepository = new SpecialiteRepository(); List <Specialite> specialites = new List <Specialite>(); specialiteRepository.FindSpecialiteByServiceId(medecin.ServiceId).ForEach( sp => specialites.Add(new Specialite { Id = sp.Id, Libelle = sp.Libelle })); ViewBag.specialite = new MultiSelectList(specialites, "Id", "Libelle"); //ViewBag.service = service.Libelle; if (medecin == null) { return(HttpNotFound()); } return(View(medecin)); }
// GET: Medecins/Services/5 public JsonResult FindSpecialitesByServiceId(int id) { SpecialiteRepository specialiteRepository = new SpecialiteRepository(); List <Specialite> specialites = new List <Specialite>(); specialiteRepository.FindSpecialiteByServiceId(id).ForEach( sp => specialites.Add(new Specialite { Id = sp.Id, Libelle = sp.Libelle })); return(Json(specialites, JsonRequestBehavior.AllowGet)); }