Пример #1
0
 public ActionResult ChangePassword(ChangePasswordFormModel form)
 {
     if (ModelState.IsValid)
     {
         FNHMVCUser user = HttpContext.User.GetFNHMVCUser();
         var command = new ChangePasswordCommand
         {
             UserId = user.UserId,
             OldPassword = form.OldPassword,
             NewPassword = form.NewPassword
         };
         IEnumerable<ValidationResult> errors = commandBus.Validate(command);
         ModelState.AddModelErrors(errors);
         if (ModelState.IsValid)
         {
             var result = commandBus.Submit(command);
             if (result.Success)
             {
                 return RedirectToAction("ChangePasswordSuccess");
             }
             else
             {
                 ModelState.AddModelError("", "The current password is incorrect or the new password is invalid.");
             }
         }
     }
     // If we got this far, something failed, redisplay form
     return View(form);
 }
Пример #2
0
 public ActionResult ChangePassword(ChangePasswordFormModel form)
 {
     if (ModelState.IsValid)
     {
         var user = HttpContext.User;
         var command = new ChangePasswordCommand
         {
             UserId = int.Parse(user.Identity.GetUserId()),
             OldPassword = form.OldPassword,
             NewPassword = form.NewPassword
         };
         IEnumerable<ValidationResult> errors = commandBus.Validate(command);
         ModelState.AddModelErrors(errors);
         if (ModelState.IsValid)
         {
             var result = commandBus.Submit(command);
             if (result.Success)
             {
                 return RedirectToAction("ChangePasswordSuccess");
             }
             else
             {
                 ModelState.AddModelError("", "The current password is incorrect or the new password is invalid.");
             }
         }
     }
      
     return View(form);
 }