Example #1
0
        public TemplateConfig AddTemplateconfig(TemplateConfigAddCommand command)
        {
            if (TemplateConfigs == null)
            {
                TemplateConfigs = new List <TemplateConfig>();
            }
            TemplateConfig templateConfig = new TemplateConfig();

            templateConfig.Init(command);
            TemplateConfigs.Add(templateConfig);

            AddEvent(ToAddOrChangeCacheEvent());
            return(templateConfig);
        }
 public void Init(TemplateConfigAddCommand command)
 {
     Id                   = Common.Common.GenerateGuid();
     TemplateId           = command.TemplateId ?? string.Empty;
     TemplatePositionCode = command.TemplatePositionCode ?? string.Empty;
     ComponentId          = command.ComponentId ?? string.Empty;
     PathToView           = command.PathToView ?? string.Empty;
     Status               = command.Status;
     ComponentType        = command.ComponentType;
     DataSource           = command.DataSource ?? string.Empty;
     CreatedDateUtc       = command.CreatedDateUtc;
     UpdatedDateUtc       = command.CreatedDateUtc;
     CreatedUid           = command.CreatedUid ?? string.Empty;
     UpdatedUid           = command.CreatedUid ?? string.Empty;
 }
Example #3
0
        public async Task <ICommandResult> Handle(TemplateConfigAddCommand 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.AddTemplateconfig(message);
                await _templateService.AddTemplateConfig(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);
            }
        }
        public async Task <CommandResult> SendCommand(TemplateConfigAddCommand command)
        {
            CommandResult commandResult = await _commandService.SendAndReceiveResult <CommandResult>(command);

            return(commandResult);
        }