Exemplo n.º 1
0
 public PartialViewResult Editer(int id)
 {
     ViewBag.type = "editer";
     client client = cnx.client.Single(c => c.id_client == id);
     ClientView clientview = new ClientView();
     clientview.updateFromModel(client);
     return PartialView("_form", clientview);
 }
Exemplo n.º 2
0
 public ActionResult Editer(ClientView clientview, int? id)
 {
     if (ModelState.IsValid)
     {
         if (id == null)
         {
             client clientx = new client();
             clientx.updateFromModel(clientview);
             cnx.client.AddObject(clientx);
         }
         else {
             client clientx = cnx.client.Where(c => c.id_client == id).Single();
             clientx.updateFromModel(clientview);
             cnx.ObjectStateManager.ChangeObjectState(clientx, EntityState.Modified);
         }
             cnx.SaveChanges();
             return Json(new { succes = 1 });
     }
     return Json(new { succes = 0,erreurs = ModelState.ListeErreurs()});
 }
Exemplo n.º 3
0
 public ActionResult NouveauViaProjet(ClientView clientview)
 {
     if (ModelState.IsValid)
     {
          client clientx = new client();
          clientx.updateFromModel(clientview);
          cnx.client.AddObject(clientx);
          cnx.SaveChanges();
          var clients = cnx.client.Where(c => c.z_actif == true);
          ViewBag.id_client = new SelectList(clients, "id_client", "nom", clientx.id_client);
          var vue = this.RenderPartialViewToString("_selectClient", null);
         return Json(new { succes = 1 , vue=vue});
     }
     return Json(new { succes = 0, erreurs = ModelState.ListeErreurs() });
 }
Exemplo n.º 4
0
 public PartialViewResult Creer()
 {
     ViewBag.type = "creer";
     ClientView clientview = new ClientView();
     return PartialView("_form", clientview);
 }
Exemplo n.º 5
0
 public void updateFromModel(ClientView clientview)
 {
     this.nom = clientview.nom;
        this.reference = clientview.reference;
        this.z_actif = true;
 }