Beispiel #1
0
        //public ActionResult AddAccount()
        //{
        //    var newAccount = new Friendscrip_Accounts();
        //    return View(newAccount);
        //}

        //[HttpPost]
        //public ActionResult AddAccount(Friendscrip_Accounts accountToAdd)
        //{
        //    var exists = _db.Friendscrip_Accounts.Where(x => x.ID == accountToAdd.ID).Any();

        //    if(!exists)
        //    {
        //        _db.Entry(accountToAdd).State = EntityState.Added;
        //    }

        //    _db.SaveChanges();

        //    return RedirectToAction("Index", "");
        //}

        public JsonResult AddAccount(Friendscrip_Accounts accountInfo)
        {
            try
            {
                var existingAccount = _db.Friendscrip_Accounts.Where(x => x.ID.Equals(accountInfo.ID)).FirstOrDefault();
                if (existingAccount == null)
                {
                    _db.Entry(accountInfo).State = EntityState.Added;
                    _db.SaveChanges();
                    ConfirmEmail emailConfirmationModel = new ConfirmEmail
                    {
                        Email = accountInfo.Email,
                        ID    = accountInfo.ID
                    };
                    return(Json(emailConfirmationModel, JsonRequestBehavior.AllowGet));
                }
                // SET SESSION VALUES #LITSQUADFAM
                Session["ID"]          = accountInfo.ID;
                Session["Email"]       = accountInfo.Email;
                Session["Friendscrip"] = accountInfo.Friendscrip;
                Session["Name"]        = accountInfo.Name;

                return(Json("AlreadyInDB", JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                return(Json("Failure", JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #2
0
 public JsonResult RemoveAccount(Friendscrip_Accounts account)
 {
     try
     {
         _db.Entry(account).State = EntityState.Deleted;
         _db.SaveChanges();
         return(Json("Success", JsonRequestBehavior.AllowGet));
     }
     catch (Exception e)
     {
         return(Json("Failure", JsonRequestBehavior.AllowGet));
     }
 }
Beispiel #3
0
        // either bind from passed in database model or ensure that view always passes db model type
        public JsonResult UpdateAccountInfo(Friendscrip_Accounts updatedInfo)
        {
            try
            {
                _db.Entry(updatedInfo).State = EntityState.Modified;

                _db.SaveChanges();

                return(Json("Success", JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                // we need a place to log our errors to
                //ApplicationLogger.LogError.
                return(Json("Failure", JsonRequestBehavior.AllowGet));
            }
        }