Esempio n. 1
0
        public Result Change(ChangeInput input)
        {
            if (input == null) throw new ArgumentNullException("input");

             var errors = new ErrorBuilder();

             if (errors.NotValid(input)) {
            return errors;
             }

             string username = this.context.CurrentUserName;
             UserWrapper user = this.repo.FindUserByName(username);

             if (errors.Not(user != null, AccountResources.Validation_UserNotExist.FormatInvariant(username))
            || errors.Not(this.passServ.PasswordEquals(input.CurrentPassword, user.Password), AccountResources.Validation_CurrentPasswordIncorrect, () => input.CurrentPassword)
            || !this.passServ.TrySetPassword(user, () => input.NewPassword, errors)) {

            return errors;
             }

             this.repo.UpdateUser(user);

             return HttpStatusCode.OK;
        }
Esempio n. 2
0
        public ActionResult Change(ChangeInput input, FormButton cancel)
        {
            if (cancel)
            return HttpSeeOther(this.Url.Action("", "~Account"));

             this.ViewData.Model = new ChangeViewModel(input);

             if (!this.ModelState.IsValid)
            return View().WithStatus(HttpStatusCode.BadRequest);

             var result = ChangeImpl(input);

             if (result.IsError)
            return View().WithErrors(result);

             return HttpSeeOther(this.Url.Action(Saved));
        }
Esempio n. 3
0
        public ActionResult Change(ChangeInput input, FormButton cancel)
        {
            if (cancel) {
            return Redirect(this.Url.Action("", "~Account"));
             }

             this.ViewData.Model = new ChangeViewModel(input);

             if (!this.ModelState.IsValid) {
            return View().WithStatus(HttpStatusCode.BadRequest);
             }

             var result = this.changer.Change(input);

             if (result.IsError) {
            return View().WithErrors(result);
             }

             return Redirect(this.Url.Action(Saved));
        }