public async Task <UserDto> Handle(CreateUserCommand request, CancellationToken cancellationToken)
        {
            var user   = _mapper.Map <User>(request);
            var result = await _userManager.CreateAsync(user, request.Password);

            if (!result.Succeeded)
            {
                throw new AccountApiException("User could not be created", result.Errors);
            }

            var createdUser = await _userManager.FindByNameAsync(user.UserName);

            await _rolePermissionsService.AddRolePermissionsAsync(user, Roles.UnconfirmedUser);

            _logger.LogInformation($"Successfully created user with id {createdUser.Id}");

            _eventBus.Publish(new UserAccountCreatedIntegrationEvent(createdUser.UserName, createdUser.Id, createdUser.Email));

            var token = await _userManager.GenerateEmailConfirmationTokenAsync(user);

            var(subject, body) =
                _emailGenerator.GenerateEmailConfirmationEmail(user.UserName, token);
            await _emailSender.SendEmailAsync(user.Email, subject, body);

            return(_mapper.Map <UserDto>(createdUser));
        }