public ActionResult RedactionToDoListDelete(int id) { using (var context = new SiteDbContext()) { ItemsToDoList team = context.ItemsToDoList.Find(id); context.Entry(team).State = System.Data.Entity.EntityState.Deleted; context.SaveChanges(); } return(RedirectToAction("Redaction", "Admin")); }
public ActionResult RedactionToDoListAjaxUpdate(int id, int state) { using (var context = new SiteDbContext()) { ItemsToDoList item = context.ItemsToDoList.Find(id); item.State = state; context.Entry(item).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } return(Json("", JsonRequestBehavior.AllowGet)); }
public ActionResult Redaction(ItemsToDoList model) { if (!ModelState.IsValid) { ModelState.AddModelError("", "Erreur dans le formulaire"); return(View(model)); } using (var context = new SiteDbContext()) { model.State = 0; context.ItemsToDoList.Add(model); context.SaveChanges(); } return(RedirectToAction("Redaction", "Admin")); }