public async Task <UserId> Handle(CreateUserCommand request, CancellationToken cancellationToken)
        {
            var user = User.Create(request.Email, _userIdGenerator, _userUniqueChecker, _passwordGenerator, _passwordHasher, cancellationToken);

            var userRepository = _dbContext.UserRepository;
            await userRepository.AddAsync(user, cancellationToken);

            await _dbContext.SaveAsync(cancellationToken);

            return(user.UserId);
        }
Ejemplo n.º 2
0
        public async Task Handle(UserCreatedEvent notification, CancellationToken cancellationToken)
        {
            var user     = notification.User;
            var password = notification.Password;

            var userCreatedIntegrationEvent = new UserCreatedIntegrationEvent(user.Email, password);
            var outboxMessageRepository     = _userDbContext.OutboxMessageRepository;
            await outboxMessageRepository.AddAsync(userCreatedIntegrationEvent, cancellationToken);

            await _userDbContext.SaveAsync(cancellationToken);
        }