Ejemplo n.º 1
0
 public void Change(TemplateConfigChangeCommand command)
 {
     Init(command);
     Id             = command.Id;
     UpdatedDateUtc = command.UpdatedDateUtc;
     UpdatedUid     = command.UpdatedUid ?? string.Empty;
 }
Ejemplo n.º 2
0
        public TemplateConfig ChangeTemplateconfig(TemplateConfigChangeCommand command)
        {
            if (TemplateConfigs == null)
            {
                TemplateConfigs = new List <TemplateConfig>();
            }
            TemplateConfig templateConfig = TemplateConfigs.FirstOrDefault(p => p.Id == command.Id);

            if (templateConfig == null)
            {
                throw new Exception("TemplateConfig not found");
            }
            templateConfig.Change(command);

            AddEvent(ToAddOrChangeCacheEvent());
            return(templateConfig);
        }
Ejemplo n.º 3
0
        public async Task <ICommandResult> Handle(TemplateConfigChangeCommand message)
        {
            try
            {
                ICommandResult result;
                RTemplate      rTemplate = await _templateService.GetById(message.TemplateId);

                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);
                TemplateConfig templateConfig = template.ChangeTemplateconfig(message);
                await _templateService.ChangeTemplateConfig(templateConfig);

                await _eventSender.Notify(template.Events);

                result = new CommandResult()
                {
                    Message  = "",
                    ObjectId = templateConfig.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);
            }
        }
Ejemplo n.º 4
0
        public async Task <CommandResult> SendCommand(TemplateConfigChangeCommand command)
        {
            CommandResult commandResult = await _commandService.SendAndReceiveResult <CommandResult>(command);

            return(commandResult);
        }