public async Task<ActionResult> ChangePassword(ChangePasswordViewModel 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)
         {
             await SignInAsync(user, isPersistent: false);
         }
         if (model.ReplaceAutoPwd == true)
         {
             ApplicationUser targetUser = db.Users.Where(u => u.Id == user.Id).Single();
             targetUser.AutoPwdReplaced = true;
             await db.SaveChangesAsync();
             Success("Thank you for updating your password.");
         }
         return RedirectToAction("Index", new { Message = ManageMessageId.ChangePasswordSuccess });
     }
     AddErrors(result);
     return View(model);
 }
 //
 // GET: /Manage/ChangePassword
 public ActionResult ChangePassword(bool? replaceAutoPwd)
 {
     ChangePasswordViewModel viewModel = new ChangePasswordViewModel();
     if (replaceAutoPwd == true)
     {
         viewModel.ReplaceAutoPwd = true;
     }
     return View(viewModel);
 }