public void CreationEnonceCompetence(ApercuViewModel AVM, int id) { List <ElementCompetence> listeElementCompetence = new List <ElementCompetence>(); List <EnonceCompetence> listeEnonceCompetence = new List <EnonceCompetence>(); List <ElementConnaissance> listeElementConnaissance = new List <ElementConnaissance>(); List <ActiviteApprentissage> listeActiviteApprentissage = new List <ActiviteApprentissage>(); List <PlanCadreCompetence> listePlanCadreCompetence = new List <PlanCadreCompetence>(); List <PlanCadreElement> listePlanCadreElement = new List <PlanCadreElement>(); List <int> ponderationEnHeure = new List <int>(); Models.Plan_Cours.PlanCours PC = _db.PlanCours.Find(id); Cours cours = _db.Cours.Find(PC.IdCours); PlanCadre planCadre = _db.PlanCadre.Find(cours.IdPlanCadre); var EnonceCompetence = from Enonce in _db.EnonceCompetence join PlanCadreCompetence in _db.PlanCadreCompetence on Enonce.IdCompetence equals PlanCadreCompetence.IdCompetence join PlanCadre in _db.PlanCadre on PlanCadreCompetence.IdPlanCadre equals PlanCadre.IdPlanCadre where PlanCadre.IdPlanCadre == planCadre.IdPlanCadre select Enonce; foreach (Models.EnonceCompetence Enonce in EnonceCompetence) { var planCadreCompetence = from PCC in _db.PlanCadreCompetence join EC in _db.EnonceCompetence on PCC.IdCompetence equals EC.IdCompetence where PCC.IdCompetence == Enonce.IdCompetence select PCC; foreach (Models.PlanCadreCompetence planCadreComp in planCadreCompetence) { listePlanCadreCompetence.Add(planCadreComp); var planCadreElement = from PCE in _db.PlanCadreElement where PCE.IdPlanCadreCompetence == planCadreComp.IdPlanCadreCompetence select PCE; foreach (Models.PlanCadreElement planCadreElements in planCadreElement) { listePlanCadreElement.Add(planCadreElements); } } var ponderation = (from PlanCadreCompetence in _db.PlanCadreCompetence where PlanCadreCompetence.IdCompetence == Enonce.IdCompetence select PlanCadreCompetence.PonderationEnHeure); foreach (int ponderationHeure in ponderation) { ponderationEnHeure.Add(Convert.ToInt32(ponderation.First())); } listeEnonceCompetence.Add(Enonce); var ElementCompetence = from Element in _db.ElementCompetence join PlanCadreElement in _db.PlanCadreElement on Element.IdElement equals PlanCadreElement.IdElement join PlanCadreCompetence in _db.PlanCadreCompetence on PlanCadreElement.IdPlanCadreCompetence equals PlanCadreCompetence.IdPlanCadreCompetence join competence in _db.EnonceCompetence on PlanCadreCompetence.IdCompetence equals competence.IdCompetence where competence.IdCompetence == Enonce.IdCompetence select Element; foreach (Models.ElementCompetence Element in ElementCompetence) { listeElementCompetence.Add(Element); var elementConnaissances = from Connaissance in _db.ElementConnaissance join PlanCadreElement in _db.PlanCadreElement on Connaissance.IdPlanCadreElement equals PlanCadreElement.IdPlanCadreElement join element in _db.ElementCompetence on PlanCadreElement.IdElement equals element.IdElement where element.IdElement == Element.IdElement select Connaissance; foreach (Models.ElementConnaissance connaissance in elementConnaissances) { listeElementConnaissance.Add(connaissance); } var activiteApprentissages = from Activite in _db.ActiviteApprentissage join PlanCadreElement in _db.PlanCadreElement on Activite.IdPlanCadreElement equals PlanCadreElement.IdElement join elementCompetence in _db.ElementCompetence on PlanCadreElement.IdElement equals elementCompetence.IdElement where elementCompetence.IdElement == Element.IdElement select Activite; foreach (Models.ActiviteApprentissage activite in activiteApprentissages) { listeActiviteApprentissage.Add(activite); } } } AVM.ListeEnonceCompetence = listeEnonceCompetence; AVM.ListeElementCompetence = listeElementCompetence; AVM.ListeActiviteApprentissage = listeActiviteApprentissage; AVM.ListeElementConnaissance = listeElementConnaissance; AVM.PonderationEnHeure = ponderationEnHeure; AVM.ListePlanCadreCompetence = listePlanCadreCompetence; AVM.ListePlanCadreElement = listePlanCadreElement; }