|
|
@@ -50,27 +50,46 @@ namespace CD67.FicheCollege.MVC.Controllers
|
|
|
etablissement educf_etablissement = educfFact.getByRne(college.CodeRne);
|
|
|
if (educf_etablissement != null)
|
|
|
{
|
|
|
- college.educfData.Add("Effectifs", educf_etablissement.etabeffectifannees.Where(e=>e.annee== college.Annee.AnneeRentree).Sum(e => e.effectif).ToString());
|
|
|
- college.educfData.Add("Effectif Bilingue", educf_etablissement.eleveannees.Where(e=>e.annee== college.Annee.AnneeRentree & e.idetablissement == 3 & e.idfiliere == 6).Count().ToString());
|
|
|
- college.educfData.Add("Demi-pensionnaires", educf_etablissement.etablissementannees.Where(e=>e.annee== college.Annee.AnneeRentree).First().demipensionnaires.ToString());
|
|
|
+ try {
|
|
|
+ college.educfData.Add("Effectifs", educf_etablissement.etabeffectifannees.Where(e => e.annee == college.Annee.AnneeRentree).Sum(e => e.effectif).ToString());
|
|
|
+ } catch { college.educfData.Add("Effectifs", "(Données introuvables)"); }
|
|
|
+
|
|
|
+ try {
|
|
|
+ college.educfData.Add("Effectif Bilingue", educf_etablissement.eleveannees.Where(e=>e.annee== college.Annee.AnneeRentree & e.idetablissement == 3 & e.idfiliere == 6).Count().ToString());
|
|
|
+ } catch { college.educfData.Add("Effectif Bilingue", "(Données introuvables)"); }
|
|
|
+
|
|
|
+ try {
|
|
|
+ college.educfData.Add("Demi-pensionnaires", educf_etablissement.etablissementannees.Where(e=>e.annee== college.Annee.AnneeRentree).First().demipensionnaires.ToString());
|
|
|
+ } catch { college.educfData.Add("Demi-pensionnaires", "(Données introuvables)"); }
|
|
|
+
|
|
|
+ try {
|
|
|
college.educfData.Add("Internes", educf_etablissement.etablissementannees.Where(e=>e.annee== college.Annee.AnneeRentree).First().capaciteeleves.ToString());
|
|
|
- college.educfData.Add("Accessibilité handicapés", educf_etablissement.accueilhandicape != 0 ? "Oui" : "Non");
|
|
|
+ } catch { college.educfData.Add("Internes", "(Données introuvables)"); }
|
|
|
+
|
|
|
+ try {
|
|
|
+ college.educfData.Add("Accessibilité handicapés", educf_etablissement.accueilhandicape != 0 ? "Oui" : "Non");
|
|
|
+ } catch { college.educfData.Add("Accessibilité handicapés", "(Données introuvables)"); }
|
|
|
+
|
|
|
+ try {
|
|
|
college.educfData.Add("Capacité Théorique", educf_etablissement.etablissementannees.Where(e => e.annee == college.Annee.AnneeRentree).First().internes.ToString());
|
|
|
+ } catch { college.educfData.Add("Capacité Théorique", "(Données introuvables)"); }
|
|
|
+ try {
|
|
|
+ List<string> liste_niveaux = new List<string>();
|
|
|
+ foreach(etabeffectifannee effectif in educf_etablissement.etabeffectifannees.Where(e => e.annee == college.Annee.AnneeRentree).OrderBy(e=>e.niveau.ordre))
|
|
|
+ {
|
|
|
+ liste_niveaux.Add(effectif.niveau.nom + ": " + effectif.effectif);
|
|
|
+ }
|
|
|
+ college.educfData.Add("Niveaux", string.Join(" - ", liste_niveaux));
|
|
|
+ } catch { college.educfData.Add("Niveaux", "(Données introuvables)"); }
|
|
|
|
|
|
- List<string> liste_niveaux = new List<string>();
|
|
|
- foreach(etabeffectifannee effectif in educf_etablissement.etabeffectifannees.Where(e => e.annee == college.Annee.AnneeRentree).OrderBy(e=>e.niveau.ordre))
|
|
|
- {
|
|
|
- liste_niveaux.Add(effectif.niveau.nom + ": " + effectif.effectif);
|
|
|
- }
|
|
|
- college.educfData.Add("Niveaux", string.Join(" - ", liste_niveaux));
|
|
|
-
|
|
|
- List<string> liste_options = new List<string>();
|
|
|
- foreach (etaboptionsannee opt in educf_etablissement.etaboptionsannees)
|
|
|
- {
|
|
|
- liste_options.Add(opt.matiereoption.nom);
|
|
|
- }
|
|
|
- college.educfData.Add("Options", string.Join(" - ", liste_options));
|
|
|
-
|
|
|
+ try {
|
|
|
+ List<string> liste_options = new List<string>();
|
|
|
+ foreach (etaboptionsannee opt in educf_etablissement.etaboptionsannees)
|
|
|
+ {
|
|
|
+ liste_options.Add(opt.matiereoption.nom);
|
|
|
+ }
|
|
|
+ college.educfData.Add("Options", string.Join(" - ", liste_options));
|
|
|
+ } catch { college.educfData.Add("Options", "(Données introuvables)"); }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -191,15 +210,59 @@ namespace CD67.FicheCollege.MVC.Controllers
|
|
|
collegeFactory.delete(ref college);
|
|
|
return RedirectToAction("Index", new { annee_id = annee_id });
|
|
|
}
|
|
|
-
|
|
|
- public ActionResult Clone(int? id, int annee_id)
|
|
|
+
|
|
|
+ public List<College> colleges_non_importes(int annee_id)
|
|
|
+ {
|
|
|
+ List<College> non_importes = new List<College>();
|
|
|
+ AnneeFactory fact = new AnneeFactory(db);
|
|
|
+ Annee annee_prec = fact.getById(annee_id - 1);
|
|
|
+
|
|
|
+ foreach (College college in annee_prec.Colleges)
|
|
|
+ {
|
|
|
+ // Pour chaque college de l'année précédente, on vérifie s'il existe dans l'année en cours en se basant sur le TokenId
|
|
|
+ if (!db.Colleges.Any(c=> c.TokenId == college.TokenId && c.Annee_Id == annee_id))
|
|
|
+ {
|
|
|
+ non_importes.Add(college.flat());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return non_importes;
|
|
|
+ }
|
|
|
+
|
|
|
+ // GET: Colleges
|
|
|
+ public ActionResult Import(int? annee_id)
|
|
|
+ {
|
|
|
+ if (annee_id == null)
|
|
|
+ {
|
|
|
+ return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
|
|
|
+ }
|
|
|
+
|
|
|
+ ImportCollegeViewModel model = new ImportCollegeViewModel();
|
|
|
+ model.Annee_Id = annee_id.Value;
|
|
|
+ model.set_liste(colleges_non_importes(annee_id.Value));
|
|
|
+
|
|
|
+ return View(model);
|
|
|
+ }
|
|
|
+
|
|
|
+ [HttpPost]
|
|
|
+ [ValidateAntiForgeryToken]
|
|
|
+ //public ActionResult Import([Bind(Include = "Annee_id, Annee_Lib,liste")] ImportCollegeViewModel model)
|
|
|
+ public ActionResult Import(int Annee_Id, List<int> colleges_ids, List<bool> selection)
|
|
|
+ //public ActionResult Import(ImportCollegeViewModel model)
|
|
|
{
|
|
|
CollegeFactory fact = new CollegeFactory(db);
|
|
|
- College college = fact.getById(id);
|
|
|
- College clone = fact.clone_to_year(college, annee_id);
|
|
|
- return RedirectToAction("Details", new { id = clone.Id });
|
|
|
+ for (int i = 0; i < selection.Count; i++)
|
|
|
+ {
|
|
|
+ if (selection[i])
|
|
|
+ {
|
|
|
+ int college_id = colleges_ids[i];
|
|
|
+ College college = fact.getById(college_id);
|
|
|
+ fact.clone_to_year(college, Annee_Id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return RedirectToAction("Index", new { annee_id = Annee_Id });
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
protected override void Dispose(bool disposing)
|
|
|
{
|
|
|
if (disposing)
|