Beispiel #1
0
        public async Task <ValidationQueryResult> ExecuteAsync(ValidateUserEmailAddressQuery query, IExecutionContext executionContext)
        {
            var userArea         = _userAreaDefinitionRepository.GetRequiredByCode(query.UserAreaCode);
            var formattingResult = _userDataFormatter.FormatEmailAddress(userArea, query.Email);

            var context = new EmailAddressValidationContext()
            {
                Email            = formattingResult,
                ExecutionContext = executionContext,
                PropertyName     = nameof(query.Email),
                UserAreaCode     = userArea.UserAreaCode,
                UserId           = query.UserId
            };

            var errors = await _emailAddressValidator.GetErrorsAsync(context);

            var result = new ValidationQueryResult(errors.FirstOrDefault());

            return(result);
        }
        private async Task ValidateNewEmailAsync(
            IUserAreaDefinition userArea,
            EmailAddressFormattingResult emailAddress,
            User user,
            IExecutionContext executionContext
            )
        {
            var context = new EmailAddressValidationContext()
            {
                Email            = emailAddress,
                ExecutionContext = executionContext,
                PropertyName     = EMAIL_PROPERTY,
                UserAreaCode     = userArea.UserAreaCode
            };

            if (user.UserId > 0)
            {
                context.UserId = user.UserId;
            }

            await _emailAddressValidator.ValidateAsync(context);
        }