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()}); }
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() }); }
/// <summary> /// Deprecated Method for adding a new object to the client EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToclient(client client) { base.AddObject("client", client); }
/// <summary> /// Create a new client object. /// </summary> /// <param name="id_client">Initial value of the id_client property.</param> public static client Createclient(global::System.Int32 id_client) { client client = new client(); client.id_client = id_client; return client; }
public void updateFromModel(client client) { this.nom = client.nom; this.reference = client.reference; this.id = client.id_client; }