public ActionResult Create(UserProfile model)
        {
            var validator = new UserProfileValidator();

            var result = validator.Validate(model);

            if (result.IsValid)
            {
                userProfileService.SaveProfile(model);

                return(RedirectToAction("Index"));
            }

            return(View(model));
        }
Example #2
0
        public void Should_FailValidationWithMessage_When_DisplayNameIsNull()
        {
            // Arrange
            var userProfileValidator = new UserProfileValidator();
            var userProfile          = new UserProfile()
            {
                DisplayName = null
            };

            // Act
            var result  = userProfileValidator.Validate(userProfile, ruleSet: "CreateUser");
            var isValid = result.IsValid;

            // Assert
            isValid.Should().Be(false);
        }
Example #3
0
        public void Should_PassValidation_When_AllRulesPass()
        {
            // Arrange
            var userProfileValidator = new UserProfileValidator();
            var userProfile          = new UserProfile()
            {
                DisplayName = "displayname"
            };

            // Act
            var result  = userProfileValidator.Validate(userProfile, ruleSet: "CreateUser");
            var isValid = result.IsValid;

            // Assert
            isValid.Should().Be(true);
        }
Example #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="userCD"></param>
        /// <param name="username"></param>
        /// <param name="oldPassword"></param>
        /// <param name="newPassword"></param>
        /// <param name="confirmNewPassword"></param>
        /// <param name="dateFormat"></param>
        /// <param name="langCD"></param>
        /// <returns></returns>
        /// <exception cref="BusinessException"><c>BusinessException</c>.</exception>
        /// <exception cref="!:EVOFramework.ValidationException"><c>ValidateException</c>.</exception>
        public int UpdateUserProfile(NZString userCD, NZString username, NZString oldPassword, NZString newPassword, NZString confirmNewPassword, NZInt dateFormat, NZInt langCD)
        {
            UserProfileValidator validator = new UserProfileValidator();

            validator.ValidateChangeUserProfile(userCD, username, oldPassword, newPassword, confirmNewPassword, dateFormat, langCD);

            IUserDAO dao = DAOFactory.CreateUserDAO(CommonLib.Common.CurrentDatabase);

            dao.UpdateUserDefaultValue(null, userCD, username, dateFormat, langCD, CommonLib.Common.CurrentUserInfomation.UserCD, CommonLib.Common.CurrentUserInfomation.Machine);
            if (!newPassword.IsNull && !confirmNewPassword.IsNull)
            {
                string encNewPassword = HashUserPassword(userCD.StrongValue, newPassword.StrongValue, true);
                dao.ChangePassword(null, userCD, new NZString(newPassword.Owner, encNewPassword), CommonLib.Common.CurrentUserInfomation.UserCD, CommonLib.Common.CurrentUserInfomation.Machine);
            }

            return(1);
        }
        public async Task ExecuteAsync(UserProfileDto userProfile)
        {
            var errors = UserProfileValidator.ValidateUserProfile(userProfile);

            if (errors.Count > 0)
            {
                ErrorMessages.AddRange(errors);
                return;
            }

            var currencies = await _currencyRepository.ListAllAsync();

            var user = UserTranslator.ToDomain(userProfile, currencies);
            await _userRepository.AddAsync(user);

            this.SuccessMessage = string.Format(SuccessMessages.USER_REGISTRATION_SUCCESS, user.FirstName, user.Id.ToString());
        }