public ActionResult Edit(Domain.Entity.Mandat mandat, int id, FormCollection collection) { MAPContext mcx = new MAPContext(); // TODO: Add update logic here try { Domain.Entity.Mandat x = mcx.Mandats.Single(a => a.idMandat == id); // Domain.Entity.Mandat x = new Domain.Entity.Mandat(); x.date_debut = mandat.date_debut; x.date_fin = mandat.date_fin; //x.idProject = mandat.idProject; //x.IdRessource = mandat.IdRessource; x.NomMandat = mandat.NomMandat; mcx.Mandats.Attach(x); mcx.SaveChanges(); //ms.Update(x); //ms.Commit(); } catch (DataException /* dex */) { //Log the error (uncomment dex variable name and add a line here to write a log. return(RedirectToAction("Edit", new { id = id, saveChangesError = true })); } return(RedirectToAction("Create", "Email")); }
public ActionResult Delete(int id, FormCollection collection) { MAPContext mc = new MAPContext(); { try { Domain.Entity.Mandat mandat = mc.Mandats.Find(id); mc.Mandats.Remove(mandat); mc.SaveChanges(); // ms.Delete(mandat); // ms.Commit(); } catch (DataException /* dex */) { //Log the error (uncomment dex variable name and add a line here to write a log. return(RedirectToAction("Delete", new { id = id, saveChangesError = true })); } return(RedirectToAction("Index")); } }
public void Commit() { dataContext.SaveChanges(); }