public PartialViewResult Editer(int id)
 {
     ViewBag.type = "editer";
     materiel materiel = cnx.materiel.Single(m => m.id_materiel == id);
     MaterielView materielview = new MaterielView();
     materielview.updateFromModel(materiel);
     return PartialView("_form", materielview);
 }
 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() });
 }
 public PartialViewResult Creer()
 {
     ViewBag.type = "creer";
     MaterielView materielview = new MaterielView();
     return PartialView("_form", materielview);
 }
Exemple #4
0
 public void updateFromModel(MaterielView materielview)
 {
     this.nom = materielview.nom;
 }