Ejemplo n.º 1
0
        public async Task UpdateResponse(UpdateResponseCommand command, Contexts contexts)
        {
            var messageService = this._messagesServiceFactory.Create(contexts);
            var response       = await this._responsesService.GetResponseByOnEvent(command.OnEvent, contexts.Server.Id);

            if (response == null)
            {
                await messageService.SendResponse(x => x.ResponseNotFound(contexts, command.OnEvent));

                return;
            }

            var defaultResponse = await this._responsesService.GetResponseByOnEvent(command.OnEvent, DomainResponse.DEFAULT_SERVER_ID);

            if (defaultResponse.Message == command.Message)
            {
                await this._responsesService.RemoveResponse(response.OnEvent, response.ServerId);

                await messageService.SendResponse(x => x.ResponseTheSameAsDefault(contexts, command.OnEvent));

                return;
            }

            await this._responsesService.UpdateResponse(response.Id, command.Message);

            await messageService.SendResponse(x => x.ResponseHasBeenUpdated(contexts, command.OnEvent, response.Message, command.Message));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> UpdateResponse([FromBody] ResponseDto request)
        {
            var command = new UpdateResponseCommand(request.Id, request.Message);

            await this.commandBus.ExecuteAsync(command);

            return(this.Ok());
        }
Ejemplo n.º 3
0
        public async Task UpdateResponse(Guid id, string message)
        {
            var command = new UpdateResponseCommand(id, message);

            await this._commandBus.ExecuteAsync(command);
        }