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); } }