public ActionResult Editer(MaterielView materielview, int? id)
 {
     if (ModelState.IsValid)
     {
         if (id == null)
         {
             materiel materielx = new materiel();
             materielx.updateFromModel(materielview);
             cnx.materiel.AddObject(materielx);
         }
         else
         {
             materiel materielx = cnx.materiel.Where(m => m.id_materiel == id).Single();
             materielx.updateFromModel(materielview);
             cnx.ObjectStateManager.ChangeObjectState(materielx, EntityState.Modified);
         }
         cnx.SaveChanges();
         return Json(new { succes = 1 });
     }
     return Json(new { succes = 0, erreurs = ModelState.ListeErreurs() });
 }
Beispiel #2
0
 public void updateFromModel(materiel matos)
 {
     this.nom = matos.nom;
     this.id = matos.id_materiel;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the materiel EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTomateriel(materiel materiel)
 {
     base.AddObject("materiel", materiel);
 }
 /// <summary>
 /// Create a new materiel object.
 /// </summary>
 /// <param name="id_materiel">Initial value of the id_materiel property.</param>
 public static materiel Createmateriel(global::System.Int32 id_materiel)
 {
     materiel materiel = new materiel();
     materiel.id_materiel = id_materiel;
     return materiel;
 }