Esempio n. 1
0
        public async Task <ActionResult> CreateAgendaTrackAsync(Guid conferenceId, CreateAgendaTrack command)
        {
            await _commandDispatcher.SendAsync(command.Bind(x => x.ConferenceId, conferenceId));

            AddResourceIdHeader(command.Id);
            return(NoContent());
        }
Esempio n. 2
0
        public async Task <ActionResult> CreateAsync(CreateSubmission command)
        {
            await _commandDispatcher.SendAsync(command);

            AddResourceIdHeader(command.Id);
            return(CreatedAtAction("Get", new { id = command.Id }, null));
        }
        public async Task <IActionResult> SendMessage(SendMessageApiRequest request)
        {
            var command = new SendMessageCommand(Guid.NewGuid(), request.ConversationId, User.GetUserId(), request.Text);
            await _commandDispatcher.SendAsync(command);

            var result = await _queryDispatcher.QueryAsync(new GetMessageQuery(command.MessageId));

            return(Ok(result));
        }
Esempio n. 4
0
        public async Task <int> CreateAsync([FromBody] ChangeProductDto dto)
        {
            var command = new CreateProductCommand {
                Dto = dto
            };
            await _commandDispatcher.SendAsync(command);

            return(command.Id);
        }
Esempio n. 5
0
        public async Task <ActionResult> Post(CreateOrder command)
        {
            await _commandDispatcher.SendAsync(command);

            return(Ok());
            //return CreatedAtAction(nameof(Get), new {orderId = command.OrderId}, null);
        }
        public async Task <IActionResult> AddLinkedServices(AddLinkedService command)
        {
            var id      = int.Parse(HttpContext.User.Claims.First(cl => cl.Type == "sub").Value);
            var context = new BaseContext(0, id, null, null);
            await commandDispatcher.SendAsync(command, context);

            return(Accepted());
        }
Esempio n. 7
0
        public async Task <ActionResult> Post(SendStory command)
        {
            await _commandDispatcher.SendAsync(command);

            var storyId = _storyRequestStorage.GetStoryId(command.Id);

            return(Created($"stories/{storyId}", null));
        }
Esempio n. 8
0
        public async Task <IActionResult> CancelOrderAsync(
            [FromBody] CancelOrderCommand command,
            CancellationToken cancellationToken = default)
        {
            var commandResult = await _commandDispatcher.SendAsync <CancelOrderCommand, CancelOrderCommandResult>(command, cancellationToken);

            return(Ok(commandResult));
        }
Esempio n. 9
0
        public Task CreateItemAsync(ItemPostDto command)
        {
            var createItemCommand = _itemCommandFactory.CreateInstance();

            createItemCommand.Description = command.Description;
            createItemCommand.Upc         = command.Upc;

            return(_dispatcher.SendAsync(createItemCommand));
        }
Esempio n. 10
0
        private async Task PublishCommandsAsync(Saga saga)
        {
            var messages = saga.GetUndispatchedCommands().Select(command => {
                dynamic typeAwareCommand = command; //this cast is required to pass the correct Type to the Notify Method. Otherwise IEvent is used as the Type
                return((Task)_commandDispatcher.SendAsync(typeAwareCommand));
            });
            await Task.WhenAll(messages);

            saga.ClearUndispatchedCommands();
        }
Esempio n. 11
0
 protected async Task SendAsync <T>(T command) where T : ICommand
 {
     if (command is IAuthenticatedCommand authenticatedCommand)
     {
         if (User?.Identity?.IsAuthenticated == true)
         {
             authenticatedCommand.UserId = Guid.Parse(User.Identity.Name);
         }
     }
     await _commandDispatcher.SendAsync(command);
 }
        public async Task HandleAsync(DeleteAllProductsCommand request)
        {
            using (var transaction = _dbContext.BeginTransaction())
            {
                foreach (var id in request.Dto.Ids)
                {
                    await _commandDispatcher.SendAsync(new DeleteProductCommand { Id = id });
                }

                await transaction.CommitAsync();
            }
        }
Esempio n. 13
0
        public async Task <IActionResult> CreateNotification(CreateNotificationCommand cmd)
        {
            var notificationId = await _commandDispatcher.SendAsync(cmd);

            return(Created($"notifications/{notificationId}", notificationId));
        }
Esempio n. 14
0
        public async Task <ActionResult> FillAttendance(FillAttendanceCommand command)
        {
            await _commandDispatcher.SendAsync <FillAttendanceCommand>(command);

            return(Ok());
        }
Esempio n. 15
0
        public async Task <IActionResult> SignUp([FromBody] SignUp command)
        {
            await _commandDispatcher.SendAsync(command);

            return(Ok());
        }
Esempio n. 16
0
        public async Task <ActionResult> CreateGroup(CreateGroupCommand command)
        {
            await _commandDispatcher.SendAsync <CreateGroupCommand>(command);

            return(Ok());
        }
Esempio n. 17
0
 public Task SendAsync <T>(T command) where T : class, ICommand
 => _commandDispatcher.SendAsync(command);
Esempio n. 18
0
        public async Task <IActionResult> PostAsync(CreateEmployeeCommand cmd)
        {
            await _commandDispatcher.SendAsync(cmd);

            return(Ok());
        }
Esempio n. 19
0
 public async Task SendAsync <TCommand>(TCommand command) where TCommand : ICommand
 => await _commandDispatcher.SendAsync(command);
Esempio n. 20
0
        public async Task <IActionResult> AddBookAsync()
        {
            await _commandDispatcher.SendAsync(new AddBookCommand("master of war", "Tom Ridle"));

            return(new OkResult());
        }
        public async Task <ActionResult> Post(CreateOrder command)
        {
            await _commandDispatcher.SendAsync(command);

            return(Created($"orders/{command.OrderId}", null));
        }
        public async Task <ActionResult> AssignToGroup(AssignToGroupCommand command)
        {
            await _commandDispatcher.SendAsync <AssignToGroupCommand>(command);

            return(Ok());
        }
Esempio n. 23
0
        public async Task <IActionResult> AddCategory(AddCategoryCommand cmd)
        {
            var result = await _commandDispatcher.SendAsync(cmd);

            return(Created($"/expenses/{result:N}", result));
        }
 public async Task HandleAsync(FriendshipCreatedIntegrationEvent @event)
 {
     await _commandDispatcher.SendAsync(new CreateConversationCommand(@event.FriendshipId, @event.FirstPerson, @event.SecondPerson));
 }
Esempio n. 25
0
        public async Task <ActionResult> CreateAsync(CreateSubmission submission)
        {
            await _commandDispatcher.SendAsync(submission);

            return(CreatedAtAction(nameof(GetAsync).ToString(), new { }));
        }
 public IActionResult Post([FromBody] CreateAnimalCommand command)
 {
     _commandDispatcher.SendAsync(command);
     return(Ok());
 }
Esempio n. 27
0
 /// <summary>
 /// Dispatches a command expecting a result
 /// </summary>
 public async Task <TResult> SendAsync <TResult>(ICommand <TResult> command)
 => await _commandDispatcher.SendAsync(command);
Esempio n. 28
0
        public async Task <ActionResult> AttendAsync(Guid eventId)
        {
            await _commandDispatcher.SendAsync(new AttendEvent(eventId, _context.Identity.Id));

            return(NoContent());
        }
        public async Task <ActionResult> Post(RateStory command)
        {
            await _commandDispatcher.SendAsync(command);

            return(NoContent());
        }
Esempio n. 30
0
 public async Task HandleAsync(FriendshipRemovedIntegrationEvent @event)
 {
     await _commandDispatcher.SendAsync(new RemoveConversationCommand(@event.FriendshipId));
 }