public ActionResult ChangePassword(ProfilePasswordModel passwordModel)
        {
            Identity identity = User.Identity;

            if (ModelState.IsValid)
            {
                try
                {
                    _membershipService.ChangePassword(identity.UserId, passwordModel.NewPassword, passwordModel.OldPassword, DateTime.FromBinary(passwordModel.Stamp));
                    TempData.AddRequestSuccessMessage(SuccessMessagesResources.PasswordChangedInfo);
                    return RedirectToAction("Edit");
                }
                catch (StaleUserException)
                {
                    ModelState.AddModelError("profile", ValidationResources.AccountStalled);
                }
                catch (UserNotExistsException)
                {
                    ModelState.AddModelError("profile", ValidationResources.AccountNotFound);
                }
                catch (PasswordsMismatchException)
                {
                    ModelState.AddModelError("profile", ValidationResources.OldPasswordsMismatchError);
                }
                catch (InvalidPasswordException)
                {
                    ModelState.AddModelError("NewPassword", ValidationResources.RegInvalidPassword);
                }
            }

            //smth went wrong
            ProfileBaseModel baseModel = null;
            ProfileModel model = new ProfileModel
            {
                BaseModel = InitBaseProfileModel(ref baseModel, _userService.Load(identity.UserId)),
                PasswordModel = InitProfilePasswordModel(ref passwordModel, null)
            };
            var resultAction = Condition()
                .DoIfNotAjax(() => View("Edit", model))
                .DoIfAjax(() => Json(new AjaxResult
                {
                    MainPanelHtml = this.RenderViewToString("~/Views/Account/Controls/ProfileControl.ascx", model)
                }, JsonRequestBehavior.AllowGet));
            return resultAction;
        }
 private ProfilePasswordModel InitProfilePasswordModel(ref ProfilePasswordModel passwdModel, User user)
 {
     if (passwdModel == null)
         passwdModel = new ProfilePasswordModel();
     if (user != null)
         passwdModel.Stamp = user.Stamp.ToBinary();
     passwdModel.Init(_membershipService.MinPasswordLength);
     return passwdModel;
 }