public TemplateTree AddTemplate(int pid, string name) { PKS_KTEMPLATE template = new PKS_KTEMPLATE(); template.CODE = Pinyin.GetPinyin(name); //template.ISDEFAULT = templateInfo.IsDefault; template.KTEMPLATECATEGORYID = pid; template.NAME = name; template.CREATEDDATE = DateTime.Now; // template.TEMPLATE = templateInfo.Template; _kTemplateRepository.Add(template); _kTemplateRepository.Submit(); var tempalteId = template.Id; var templateTrees = from tem in _kTemplateRepository.GetQuery() join cat in _kTCategoryRepository.GetQuery() on tem.KTEMPLATECATEGORYID equals cat.Id where cat.Id == pid && tem.Id == tempalteId select new TemplateTree { Id = tem.Id, SubSystemId = cat.SUBSYSTEMID, TemplateUrlId = cat.KTEMPLATEURLID, InstanceClass = cat.INSTANCECLASS, Code = tem.CODE, Name = tem.NAME, Template = tem.TEMPLATE, IsDefault = tem.ISDEFAULT, TemplateCategoryId = tem.KTEMPLATECATEGORYID, NodeId = "tem_" + tem.Id, ParentNodeId = "cat_" + cat.Id }; return(templateTrees.FirstOrDefault()); }
public bool AddTemplates(List <TemplateTree> templateTrees) { if (templateTrees != null) { List <PKS_KTEMPLATE> templates = new List <PKS_KTEMPLATE>(); foreach (var tree in templateTrees) { PKS_KTEMPLATE template = new PKS_KTEMPLATE(); template.CODE = tree.Code; template.ISDEFAULT = false; template.KTEMPLATECATEGORYID = tree.TemplateCategoryId; template.NAME = tree.Name; templates.Add(template); } _kTemplateRepository.AddRange(templates); } return(true); }
public bool AddTemplate(TemplateTree templateInfo) { if (templateInfo.IsTemplate) { PKS_KTEMPLATE template = new PKS_KTEMPLATE(); template.CODE = templateInfo.Code; template.ISDEFAULT = templateInfo.IsDefault; template.KTEMPLATECATEGORYID = templateInfo.TemplateCategoryId; template.NAME = templateInfo.Name; template.TEMPLATE = templateInfo.Template; if (templateInfo.Id > 0) { template.Id = templateInfo.Id; template.LASTUPDATEDDATE = DateTime.Now; _kTemplateRepository.Update(template); } else { template.CREATEDDATE = DateTime.Now; _kTemplateRepository.Add(template); } } else { PKS_KTEMPLATE_CATEGORY category = new PKS_KTEMPLATE_CATEGORY(); category.CODE = templateInfo.Code; category.SUBSYSTEMID = templateInfo.SubSystemId; category.NAME = templateInfo.Name; category.KTEMPLATEURLID = templateInfo.TemplateUrlId; category.INSTANCECLASS = templateInfo.InstanceClass; if (templateInfo.Id > 0) { category.Id = templateInfo.Id; _kTCategoryRepository.Update(category); } else { _kTCategoryRepository.Add(category); } } return(true); }