Ejemplo n.º 1
0
        public ActionResult EditProfileAccount()
        {
            var UserId = User.Identity.GetUserId();
            var user   = db.Users.Where(a => a.Id == UserId).SingleOrDefault();
            EditProfileAccount account = new EditProfileAccount();

            account.Email    = user.Email;
            account.UserName = user.UserName;
            return(View(account));
        }
Ejemplo n.º 2
0
        public ActionResult EditProfileAccount(EditProfileAccount account)
        {
            var UserId = User.Identity.GetUserId();
            var user   = db.Users.Where(a => a.Id == UserId).SingleOrDefault();

            if (!UserManager.CheckPassword(user, account.Password))
            {
            }
            else
            {
                var newpassword = UserManager.PasswordHasher.HashPassword(account.NewPassword);
                user.UserName        = account.UserName;
                user.Email           = account.Email;
                user.PasswordHash    = newpassword;
                db.Entry(user).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index", "Home"));
            }
            return(View(account));
        }