|
|
@@ -154,6 +154,54 @@ namespace CD67.FicheCollege.MVC.Controllers
|
|
|
return RedirectToAction("Index", new { annee_id = actionEdu.AnneeId });
|
|
|
}
|
|
|
|
|
|
+ public List<ActionEdu> actions_non_importees(int annee_id)
|
|
|
+ {
|
|
|
+ List<ActionEdu> non_importees = new List<ActionEdu>();
|
|
|
+ AnneeFactory fact = new AnneeFactory(db);
|
|
|
+ Annee annee_prec = fact.getById(annee_id - 1);
|
|
|
+ foreach (ActionEdu actionEdu in annee_prec.ActionsEdu)
|
|
|
+ {
|
|
|
+ // 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.ActionsEdu.Any(a => a.TokenId == actionEdu.TokenId && a.AnneeId == annee_id))
|
|
|
+ {
|
|
|
+ non_importees.Add(actionEdu.flat());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return non_importees;
|
|
|
+ }
|
|
|
+
|
|
|
+ // GET: Colleges
|
|
|
+ public ActionResult Import(int? annee_id)
|
|
|
+ {
|
|
|
+ if (annee_id == null)
|
|
|
+ {
|
|
|
+ return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
|
|
|
+ }
|
|
|
+
|
|
|
+ ImportActionEduViewModel model = new ImportActionEduViewModel();
|
|
|
+ model.Annee_Id = annee_id.Value;
|
|
|
+ model.set_liste(actions_non_importees(annee_id.Value));
|
|
|
+
|
|
|
+ return View(model);
|
|
|
+ }
|
|
|
+
|
|
|
+ [HttpPost]
|
|
|
+ [ValidateAntiForgeryToken]
|
|
|
+ public ActionResult Import(int Annee_Id, List<int> actionsEdu_ids, List<bool> selection)
|
|
|
+ {
|
|
|
+ ActionEduFactory fact = new ActionEduFactory(db);
|
|
|
+ for (int i = 0; i < selection.Count; i++)
|
|
|
+ {
|
|
|
+ if (selection[i])
|
|
|
+ {
|
|
|
+ int actionEdu_id = actionsEdu_ids[i];
|
|
|
+ ActionEdu actionEdu = fact.getById(actionEdu_id);
|
|
|
+ fact.clone_to_year(actionEdu, Annee_Id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return RedirectToAction("Index", new { annee_id = Annee_Id });
|
|
|
+ }
|
|
|
+
|
|
|
public ActionResult Up(int? id)
|
|
|
{
|
|
|
if (id == null)
|