コード例 #1
0
        public void Change(TemplateChangeCommand command)
        {
            Add(command, false);
            Id             = command.Id;
            UpdatedDateUtc = command.UpdatedDateUtc;
            UpdatedUid     = command.UpdatedUid ?? string.Empty;

            AddEvent(ToAddOrChangeCacheEvent());
        }
コード例 #2
0
        public async Task <ICommandResult> Handle(TemplateChangeCommand message)
        {
            try
            {
                ICommandResult result;
                RTemplate      rTemplate = await _templateService.GetById(message.Id);

                if (rTemplate == null)
                {
                    result = new CommandResult()
                    {
                        Message      = "Template not found",
                        ObjectId     = "",
                        Status       = CommandResult.StatusEnum.Fail,
                        ResourceName = ResourceKey.Template_NotFound
                    };
                    return(result);
                }
                RTemplateConfig[] rTemplateConfigs = await _templateService.GetTemplateConfigByTemplateId(rTemplate.Id);

                Template template = new Template(rTemplate, rTemplateConfigs);
                template.Change(message);
                await _templateService.Change(template);

                await _eventSender.Notify(template.Events);

                result = new CommandResult()
                {
                    Message  = "",
                    ObjectId = template.Id,
                    Status   = CommandResult.StatusEnum.Sucess
                };
                return(result);
            }
            catch (Exception e)
            {
                e.Data["Param"] = message;
                ICommandResult result = new CommandResult()
                {
                    Message = e.Message,
                    Status  = CommandResult.StatusEnum.Fail
                };
                return(result);
            }
        }
コード例 #3
0
        public async Task Edit()
        {
            var template = await this.Add();

            var message = new HttpRequestMessage(HttpMethod.Put, API);
            var command = new TemplateChangeCommand
            {
                Id     = template.Id,
                Format = this.GetConfig(),
                Name   = this.GetRandom()
            };

            message.AddJsonContent(command);
            var responseMessage = await this.HttpClient.SendAsync(message);

            await responseMessage.AsResult();

            var newTemplate = await this.Get(template.Id);

            Assert.NotEqual(command.Name, template.Name);
            Assert.NotEqual(command.Format, template.Format);
            Assert.Equal(command.Name, newTemplate.Name);
            Assert.Equal(command.Format, newTemplate.Format);
        }
コード例 #4
0
        public async Task <object> Put(TemplateChangeCommand command)
        {
            await this._mediator.Send(command);

            return(ResponseResult.Success);
        }
コード例 #5
0
 public Task Handle(TemplateChangeCommand command)
 {
     return(this.Update(command.Id, s => s.Change(command)));
 }
コード例 #6
0
 public void Change(TemplateChangeCommand command) => this.Apply <TemplateChangeEvent>(command);
コード例 #7
0
        public async Task <CommandResult> SendCommand(TemplateChangeCommand command)
        {
            CommandResult commandResult = await _commandService.SendAndReceiveResult <CommandResult>(command);

            return(commandResult);
        }