Пример #1
0
        public async Task <UserAccount> Handle(CreateUserCommand command, CancellationToken cancellationToken)
        {
            var password = PasswordHelper.Encrypt(command.Password);

            var user = new User(command.Name, command.Email, password, command.Gender, command.BirthDate);

            var userValidator = new UserValidator();
            var result        = await userValidator.ValidateAsync(user, default);

            if (!result.IsValid)
            {
                throw new Exception(String.Join("--", result.Errors));
            }

            var userAccount = await _userAccountService.CreateUserAndAccount(user);

            return(userAccount);
        }