Пример #1
0
        public ActionResult EditProfile(ProfileModel input)
        {
            if (LoggedUser.Id != input.Id)
                throw new Exception("Your are not allowed to modify somebodies' else profile");

            if (ModelState.IsValid)
            {
                var editProfileCommand = Mapper.Map<EditProfileCommand>(input);

                CommandProcessor.Process(editProfileCommand);

                if (editProfileCommand.IsValid)
                {
                    _loggedUserService.RefreshLoggedUserInformation();

                    input.Password = input.ValidatePassword = string.Empty;

                    Notify("Your profile has been succesfully updated", NotifyType.Success, NotifyPosition.Top);

                    return View(input);
                }
            }

            input.Password = input.ValidatePassword = string.Empty;

            return View(input);
        }
Пример #2
0
        public ActionResult Register(ProfileModel input)
        {
            if (ModelState.IsValid)
            {
                var registerUserCommand = Mapper.Map<RegisterUserCommand>(input);
                CommandProcessor.Process(registerUserCommand);

                if (registerUserCommand.IsValid)
                {
                    return Login(Mapper.Map<LoginModel>(input));
                }
            }

            input.Password = string.Empty;

            return View(input);
        }