Пример #1
0
        public ActionResult PasswordChange(PasswordModel model)
        {
            Client Client = _clientProfileControl.GetClient((int)Session["AccountId"]);

            if (ModelState.IsValid)
            {
                if (!Client.DoEncyptedPassowrdsMacth(model.OldPassword))
                {
                    var errMessage = "Entered password is wrong";

                    ModelState.AddModelError("", errMessage);
                    return(View(model));
                }
                if (!model.DoPasswordsMatch())
                {
                    var errMessage = "The entered password matches the current one";

                    ModelState.AddModelError("", errMessage + "! Pick a new password");
                    return(View(model));
                }

                model.ExcryptThePassword();

                _clientProfileControl.EditPassword(Client.Id, model.NewPassword);
            }
            return(RedirectToAction("EditProfile", new { @client = Client }));
        }