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() });
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Deprecated Method for adding a new object to the recurrence EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTorecurrence(recurrence recurrence)
 {
     base.AddObject("recurrence", recurrence);
 }
Esempio n. 3
0
 public JsonResult Dupliquer(DupliquerView duplicate)
 {
     if (ModelState.IsValid)
     {
         temps tps = cnx.temps.Where(t => t.id_temps == duplicate.id_temps).Single();
         recurrence rec = new recurrence();
         tps.recurrence = rec;
         DateTime debut = tps.date_debut;
         DateTime fin = tps.date_fin;
         bool absence = tps.type_temps.absence;
         int diffDays = duplicate.frequenceInt;
         while (debut.AddDays(diffDays) < duplicate.dateFin.AddDays(1))
         {
             temps tpsCopie = tps.ClonerPourDupliquer();
             debut = debut.AddDays(diffDays);
             fin = fin.AddDays(diffDays);
             tpsCopie.date_debut = debut;
             tpsCopie.date_fin = fin;
             //verification si on le garde ou pas
             // si c'est un samedi on garde seulement si c'est une astreinte (type_temps=1) ou un congé annuel (type_temps=6)
             if ((debut.DayOfWeek == DayOfWeek.Saturday) && (tpsCopie.id_type_temps != 1)) continue;
             // si c'est un dimanche on garde seulement si c'est une astreinte (type_temps=1)
             if ((debut.DayOfWeek == DayOfWeek.Sunday) && (tpsCopie.id_type_temps != 1)) continue;
             if (this.IsThereAchevauchement(tpsCopie, absence) == false)
             {
                 tpsCopie.recurrence = rec;
                 cnx.AddTotemps(tpsCopie);
             }
         }
         cnx.SaveChanges();
         return Json(new { succes = 1 });
     }
     else
     {
         return Json(new { succes = 0, erreurs = ModelState.ListeErreurs() });
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Create a new recurrence object.
 /// </summary>
 /// <param name="id_recurrence">Initial value of the id_recurrence property.</param>
 public static recurrence Createrecurrence(global::System.Int32 id_recurrence)
 {
     recurrence recurrence = new recurrence();
     recurrence.id_recurrence = id_recurrence;
     return recurrence;
 }