public async Task<ActionResult> EditPassword(EditPasswordModel model)
 {
     if (!ModelState.IsValid)
     {
         return View(model);
     }
     var result = await UserManager.ChangePasswordAsync(User.Identity.GetUserId(), model.OldPassword, model.NewPassword);
     if (result.Succeeded)
     {
         var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());
         if (user != null)
         {
             AuthenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie, DefaultAuthenticationTypes.TwoFactorCookie);
             return RedirectToAction("Login", "Account");
         }
         return RedirectToAction("Index", "Main");
     }
     else
     {
         ModelState.AddModelError("", "Неверный пароль");
     }
     return View(model);
 }
        public ActionResult EditPassword(EditPasswordModel model)
        {
            if (ModelState.IsValid)
            {
                var user = _usersRepositoryHandler.GetUserByEmail(FormsAuthentication.Decrypt
                    (Request.Cookies[FormsAuthentication.FormsCookieName].Value).Name);
                if (user == null) return View(model);

                user.Password = model.NewPassword;
                _usersRepositoryHandler.Update(user);

                FormsAuthentication.SignOut();
                return RedirectToAction("Login", "Account");
            }
            else
            {
                ModelState.AddModelError("", "Неверный пароль");
            }
            return View(model);
        }