internal void RemoveAgentFromRoute(Education_Matrice matriceSelected, string nameGrpAgentSelected) { Education_Matrice_GrLearner itemDb = db.Education_Matrice_GrLearner //.Include("Education_Matrice") .Where(x => x.MatriceGrLearner_Matrice == matriceSelected.Matrice_Id && x.Education_GroupLearner.GroupLearner_Actif == true && x.Education_GroupLearner.GroupLearner_Name == nameGrpAgentSelected) .FirstOrDefault(); itemDb.MatriceGrLearner_Actif = false; db.SaveChanges(); List <Education_GroupLearner_Agent> ListgrpLearner = db.Education_GroupLearner_Agent.Where(x => x.Education_GroupLearner.GroupLearner_Name == nameGrpAgentSelected && x.Education_GroupLearner.GroupLearner_Actif == true) .ToList(); foreach (var grpagent in ListgrpLearner) { Education_Matrice_Agent agentItemDb = db.Education_Matrice_Agent //.Include("Education_Matrice") .Where(x => x.Education_Matrice_Formation.MatriceFormation_Matrice == matriceSelected.Matrice_Id && x.MatriceAgent_Agent == grpagent.Education_Agent.Agent_Id) .FirstOrDefault(); agentItemDb.MatriceAgent_Actif = false; db.SaveChanges(); } }
public void AssignGrpAgentToRoute(Education_Matrice matriceSelected, Education_GroupLearner agentGrpSelected) { Education_GroupLearner GrpAgent = db.Education_GroupLearner .Where(y => y.GroupLearner_Id == agentGrpSelected.GroupLearner_Id).FirstOrDefault(); if (GrpAgent == null) { Education_Matrice_GrLearner newRecord = new Education_Matrice_GrLearner() { MatriceGrLearner_Matrice = matriceSelected.Matrice_Id, MatriceGrLearner_GroupeLearner = GrpAgent.GroupLearner_Id }; db.Education_Matrice_GrLearner.Add(newRecord); db.SaveChanges(); } }