コード例 #1
0
 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));
 }
コード例 #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            CommunicationsPreference commPref = db.CommunicationsPreferences.Single(f => f.Id == id);

            db.CommunicationsPreferences.DeleteObject(commPref);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #3
0
        //
        // GET: /Admin/Default1/Edit/5

        public ActionResult Edit(int id)
        {
            CommunicationsPreference commPref = db.CommunicationsPreferences.Single(f => f.Id == id);

            return(View(commPref));
        }
コード例 #4
0
        //
        // GET: /Admin/Default1/Details/5

        public ViewResult Details(int id)
        {
            CommunicationsPreference commPref = db.CommunicationsPreferences.Single(f => f.Id == id);

            return(View(commPref));
        }