public JsonResult Dupliquer(DupliquerView duplicate)
 {
     if (ModelState.IsValid)
     {
         reservation resa = cnx.reservation.Where(r => r.id_reservation == duplicate.id_resa).Single();
         recurrence rec = new recurrence();
         resa.recurrence = rec;
         DateTime debut = resa.date_debut;
         DateTime fin = resa.date_fin;
         int diffDays = duplicate.frequenceInt;
         while (debut.AddDays(diffDays) < duplicate.dateFin.AddDays(1))
         {
             reservation resaCopie = resa.ClonerPourDupliquer();
             debut = debut.AddDays(diffDays);
             fin = fin.AddDays(diffDays);
             resaCopie.date_debut = debut;
             resaCopie.date_fin = fin;
             //verification si on le garde ou pas
             // si c'est un samedi ou un dimanche
             if ((debut.DayOfWeek == DayOfWeek.Saturday) || (debut.DayOfWeek == DayOfWeek.Sunday) ) continue;
             if (cnx.reservation.Where(r => r.id_materiel == resaCopie.id_materiel && r.date_fin > resaCopie.date_debut && r.date_debut < resaCopie.date_fin && r.employe.z_actif == true).Any() == false)
             {
                 resaCopie.recurrence = rec;
                 cnx.AddToreservation(resaCopie);
             }
         }
         cnx.SaveChanges();
         return Json(new { succes = 1 });
     }
     else
     {
         return Json(new { succes = 0, erreurs = ModelState.ListeErreurs() });
     }
 }
 public PartialViewResult Dupliquer(int id)
 {
     reservation resa = cnx.reservation.Where(r => r.id_reservation == id).Single();
     DupliquerView dpv = new DupliquerView();
     dpv.dateFin = resa.date_debut.AddDays(1);
     dpv.id_resa = id;
     return PartialView("_formDupliquer", dpv);
 }