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

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

                return;
            }
            var responseForThisServer = await this._responsesService.GetResponseByOnEvent(command.OnEvent, contexts.Server.Id);

            if (responseForThisServer != null)
            {
                await messageService.SendResponse(x => x.ResponseAlreadyExists(contexts, command.OnEvent));

                return;
            }

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

            if (defaultResponse.Message == command.Message)
            {
                await messageService.SendResponse(x => x.ResponseAlreadyExists(contexts, command.OnEvent));

                return;
            }

            await this._responsesService.AddCustomResponse(command.OnEvent, command.Message, contexts.Server.Id);

            await messageService.SendResponse(x => x.ResponseHasBeenAdded(contexts, command.OnEvent));
        }
Ejemplo n.º 2
0
        public async Task AddResponse(string onEvent, string message, ulong serverId = 0)
        {
            var addResponse = new Response(onEvent, message, serverId);
            var command     = new AddResponseCommand(addResponse);

            await this._commandBus.ExecuteAsync(command);
        }
Ejemplo n.º 3
0
        public async Task AddCustomResponse(string onEvent, string message, ulong serverId)
        {
            var query       = new GetResponseQuery(onEvent);
            var response    = (await this._queryBus.ExecuteAsync(query)).Response;
            var addResponse = new Response(onEvent, message, serverId, response.AvailableVariables);
            var command     = new AddResponseCommand(addResponse);

            await this._commandBus.ExecuteAsync(command);
        }