public async Task<ActionResult> ResetPassword(ChangePasswordAndConfirmEmailVm model)
 {
     if (!ModelState.IsValid)
     {
         return View(model);
     }
     var user = await UserManager.FindByIdAsync(model.userId);
     if (user == null)
     {
         // Don't reveal that the user does not exist
         return RedirectToAction("ResetPasswordConfirmation", "Account");
     }
     var result = await UserManager.ResetPasswordAsync(user.Id, model.code, model.newPassword);
     if (result.Succeeded)
     {
         return RedirectToAction("ResetPasswordConfirmation", "Account");
     }
     AddErrors(result);
     return View();
 }
        public async Task<ActionResult> ConfirmEmailAndChangePassword( ChangePasswordAndConfirmEmailVm Model )
        {
            if (ModelState.IsValid)
            {
                IdentityResult result;
                result = await UserManager.ConfirmEmailAsync(HttpUtility.UrlDecode(Model.userId), HttpUtility.UrlDecode(Model.code));
                if (!result.Succeeded)
                {
                    ModelState.AddModelError("", "Произошла ошибка при подтверждении Email. " + result.Errors.First());
                    return View(Model);
                }
                result = await UserManager.RemovePasswordAsync(Model.userId);
                if (! result.Succeeded)
                {
                    ModelState.AddModelError("", "Произошла ошибка при временного пароля. "+result.Errors.First());
                    return View(Model);
                } 
                result = await UserManager.AddPasswordAsync(Model.userId, Model.confirmNewPassword);
                if (!result.Succeeded)
                {
                    ModelState.AddModelError("", "Произошла ошибка при добавлении нового пароля. " + result.Errors.First());
                    return View(Model);
                }

                return RedirectToAction("Welcome");

            }
            return View(Model);
        }
 public ActionResult ResetPassword(string userId, string code)
 {
     ChangePasswordAndConfirmEmailVm model = new ChangePasswordAndConfirmEmailVm { userId = userId, code = code };
     return code == null ? View("Error") : View(model);
 }
 public ActionResult ConfirmEmailAndChangePassword(string userId, string code)
 {
     if (userId == null || code == null)
     {
         return View("Error");
     }
     ChangePasswordAndConfirmEmailVm model = new ChangePasswordAndConfirmEmailVm { userId = userId, code = code };
     return View("ConfirmEmailAndChangePassword",model);
 }