Example #1
0
 public reservation ClonerPourDupliquer()
 {
     reservation resa = new reservation();
     resa.id_employe = this.id_employe;
     resa.id_materiel = this.id_materiel;
     resa.commentaires = this.commentaires;
     return resa;
 }
Example #2
0
 public void updateFromModel(reservation resa)
 {
     this.id_employe = resa.id_employe;
     this.commentaires = resa.commentaires;
     this.fin = resa.date_fin;
     this.debut = resa.date_debut;
     this.id_matos = resa.id_materiel;
     this.id_resa = resa.id_reservation;
 }
        public JsonResult Editer(int? id, ReservationView resaview)
        {
            if (ModelState.IsValid)
            {
                reservation resa;
                object retour;
                var resas = cnx.reservation.Where(r => r.id_materiel == resaview.id_matos && r.date_fin > resaview.debut && r.date_debut < resaview.fin && r.employe.z_actif == true);
                if (id.HasValue)
                {
                    resas = resas.Where(r => r.id_reservation != id);
                }
                if (resas.Any()) return Json(new { succes = 0, message = "La ressource n'est pas disponible." });
                if (!id.HasValue)
                {
                    resa = new reservation();
                    resa.UpdateFromModelView(resaview);

                    cnx.AddToreservation(resa);
                    cnx.SaveChanges();
                    retour = new { succes = 1, creation=1, resa = resa.PourJson() };
                } else {
                    resa=cnx.reservation.Where(r=>r.id_reservation==id).Single();
                    resa.UpdateFromModelView(resaview);
                    cnx.ObjectStateManager.ChangeObjectState(resa, EntityState.Modified);
                    cnx.SaveChanges();
                    retour = new { succes = 1, creation = 0 };
                }

                return Json(retour);
            }
            else
            {
                return Json(new { succes = 0, message = "Une erreur s'est produite" });
            }
        }
Example #4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the reservation EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToreservation(reservation reservation)
 {
     base.AddObject("reservation", reservation);
 }
Example #5
0
 /// <summary>
 /// Create a new reservation object.
 /// </summary>
 /// <param name="id_reservation">Initial value of the id_reservation property.</param>
 /// <param name="date_debut">Initial value of the date_debut property.</param>
 /// <param name="date_fin">Initial value of the date_fin property.</param>
 /// <param name="id_employe">Initial value of the id_employe property.</param>
 /// <param name="id_materiel">Initial value of the id_materiel property.</param>
 public static reservation Createreservation(global::System.Int32 id_reservation, global::System.DateTime date_debut, global::System.DateTime date_fin, global::System.Int32 id_employe, global::System.Int32 id_materiel)
 {
     reservation reservation = new reservation();
     reservation.id_reservation = id_reservation;
     reservation.date_debut = date_debut;
     reservation.date_fin = date_fin;
     reservation.id_employe = id_employe;
     reservation.id_materiel = id_materiel;
     return reservation;
 }