public ActionResult Edit(ProfileEditForm form)
        {
            var user = (AppUser)Session["User"];

            if (user == null)
            {
                return(RedirectToAction("SignIn", "Login"));
            }

            if (!ModelState.IsValid)
            {
                return(View("Edit", form));
            }

            var dbUser = db.AppUsers.SingleOrDefault(u => u.Id == user.Id);

            if (dbUser == null)
            {
                return(HttpNotFound());
            }

            dbUser.Update(form);
            var updatedUser = new AppUser();

            updatedUser.GetLoginData(dbUser);
            Session["User"] = updatedUser;
            db.SaveChanges();

            return(RedirectToAction("Home", "Home"));
        }
Beispiel #2
0
 public void Update(ProfileEditForm form)
 {
     Password  = form.Password;
     FirstName = form.FirstName;
     LastName  = form.LastName;
     Gender    = form.Gender;
     UMCN      = form.UMCN;
     Phone     = form.Phone;
     Email     = form.Email;
 }
        public ActionResult Edit()
        {
            var user = (AppUser)Session["User"];

            if (user == null)
            {
                return(RedirectToAction("SignIn", "Login"));
            }

            var dbUser = db.AppUsers.SingleOrDefault(u => u.Id == user.Id);

            if (dbUser == null)
            {
                return(HttpNotFound());
            }

            var editForm = new ProfileEditForm(dbUser);

            return(View(editForm));
        }