Beispiel #1
0
        public async Task<string> ValidateUser(UserGetOptions options)
        {
            try
            {
                _logger.LogInformation("Start user name and email validating.");

                string result = ValidationUtilities.ValidateUserName(options.Username);
                if (!string.IsNullOrEmpty(result))
                    return result;

                result = ValidationUtilities.ValidateEmail(options.Email);
                if (!string.IsNullOrEmpty(result))
                    return result;

                var users = await _dao.Get(options);
                if (users.Where(o => o.Username != options.Username).Count() > 0)
                {
                    string message = "User with same user name or email have been already created. Please try another or try to sign in.";
                    _logger.LogInformation(message);
                    return message;
                }

                _logger.LogInformation("User name and email successfuly validated.");
                return null;
            }
            catch (Exception exception)
            {
                _logger.LogError(exception.Message);
                throw exception;
            }
        }