public ActionResult Edit(CommunicationsPreference commPref) { if (ModelState.IsValid) { db.CommunicationsPreferences.Attach(commPref); db.ObjectStateManager.ChangeObjectState(commPref, EntityState.Modified); try { db.SaveChanges(); return(RedirectToAction("Index")); } catch (Exception ex) { var msg = ex.Message; if (ex.InnerException != null) { var inner = ex.InnerException; while (inner.InnerException != null) { inner = inner.InnerException; } msg = inner.Message; } if (msg.Contains("UNIQUE")) { msg = "There is already a Communications Preference with that name"; } ModelState.AddModelError("", msg); } } return(View(commPref)); }
public ActionResult DeleteConfirmed(int id) { CommunicationsPreference commPref = db.CommunicationsPreferences.Single(f => f.Id == id); db.CommunicationsPreferences.DeleteObject(commPref); db.SaveChanges(); return(RedirectToAction("Index")); }
// // GET: /Admin/Default1/Edit/5 public ActionResult Edit(int id) { CommunicationsPreference commPref = db.CommunicationsPreferences.Single(f => f.Id == id); return(View(commPref)); }
// // GET: /Admin/Default1/Details/5 public ViewResult Details(int id) { CommunicationsPreference commPref = db.CommunicationsPreferences.Single(f => f.Id == id); return(View(commPref)); }