Пример #1
0
        protected override async Task ExecuteAsync(CancellationToken cancellationToken)
        {
            while (!cancellationToken.IsCancellationRequested)
            {
                await _commandDispatcher.ExecuteAsync(_commandFactory());

                await Task.Delay(_delay, cancellationToken);
            }
        }
Пример #2
0
        protected override async Task ExecuteAsync(CancellationToken cancellationToken)
        {
            using (IServiceScope serviceScope = _serviceProvider.CreateScope())
            {
                ICommandPublisher commandPublisher = serviceScope.ServiceProvider.GetRequiredService <ICommandPublisher>();

                while (!cancellationToken.IsCancellationRequested)
                {
                    await commandPublisher.ExecuteAsync(_commandFactory());

                    await Task.Delay(_delay, cancellationToken);
                }
            }
        }
Пример #3
0
        public async Task <ActionResult <UserLoginResponse> > Register([FromBody] RegisterUserRequest request)
        {
            EmailRegisteredQueryResult result = await _queryPublisher.ExecuteAsync(new EmailRegisteredQuery(request.Email));

            if (!result.IsRegistered)
            {
                await _commandPublisher.ExecuteAsync(new RegisterUserCommand(request.Email));

                SecurityTokenForUserQueryResult tokenResult = await _queryPublisher.ExecuteAsync(new SecurityTokenForUserQuery(request.Email));

                return(new UserLoginResponse {
                    Token = tokenResult.Token
                });
            }

            return(new UserLoginResponse());
        }
Пример #4
0
 public async Task <AnswerQuizQuestionResult> Answer([FromBody] QuestionAnswerRequest request) => await _commandPublisher.ExecuteAsync(new AnswerQuizQuestionCommand(User.Id(), request.QuestionId, request.AnswerId));
Пример #5
0
 public async Task Add([FromBody] AddFriendRequest request) => await _commandPublisher.ExecuteAsync(new AddFriendCommand(User.Id(), request.Email));
        public async Task ExecuteAsync_Command_Executed()
        {
            await _publisher.ExecuteAsync(new TestCommand());

            _receivedMessages.Should().Be(1);
        }
Пример #7
0
 public async Task Update([FromBody] UpdateProfileRequest request)
 {
     var command = new UpdateProfileCommand(HttpContext.User.Id(), request.DisplayName, request.City, request.Street, request.PostalCode);
     await _commandPublisher.ExecuteAsync(command);
 }