示例#1
0
        private ScripEntities _db = new ScripEntities(); // connection to database

        public JsonResult AddNewItem(Friendscrip_Items newItem)
        {
            try
            {
                _db.Entry(newItem).State = EntityState.Added;
                _db.SaveChanges();
                // return newItem instead of "Success"
                return(Json("Success", JsonRequestBehavior.AllowGet));
            } catch (Exception e)
            {
                return(Json("Failure", JsonRequestBehavior.AllowGet));
            }
        }
 public ActionResult Confirm(ConfirmEmail emails)
 {
     if (emails.Email.Equals(emails.SameEmail))
     {
         var account = _db.Friendscrip_Accounts.Where(x => x.ID.Equals(emails.ID)).FirstOrDefault();
         if (account != null)
         {
             if (account.Email.Equals(emails.Email))
             {
                 // do nothing
             }
             else
             {
                 account.Email = emails.Email;
                 _db.SaveChanges();
             }
         }
         return(RedirectToAction("Index"));
     }
     return(View(emails.Email, emails.ID));
 }