Example #1
0
 protected override void BeforeSave(S_T_NodeTemplate entity, bool isNew)
 {
     if (isNew)
     {
         var root = new S_T_NodeTemplate_Detail();
         root.ID             = Formula.FormulaHelper.CreateGuid();
         root.FullID         = root.ID;
         root.Name           = entity.Name;
         root.Code           = entity.Code;
         root.NodeType       = "Root";
         root.ParentID       = "";
         root.NodeTemplateID = entity.ID;
         root.SortIndex      = 0;
         this.entities.Set <S_T_NodeTemplate_Detail>().Add(root);
     }
 }
Example #2
0
        public JsonResult AddChild(string parentID)
        {
            var parent = this.GetEntityByID <S_T_NodeTemplate_Detail>(parentID);
            var child  = new S_T_NodeTemplate_Detail();

            child.ID             = Formula.FormulaHelper.CreateGuid();
            child.FullID         = parent.FullID + "." + child.ID;
            child.Name           = "新建节点";
            child.Code           = "";
            child.NodeType       = "";
            child.ParentID       = parent.ID;
            child.NodeTemplateID = parent.NodeTemplateID;
            child.SortIndex      = this.entities.Set <S_T_NodeTemplate_Detail>().Count(c => c.ParentID == parentID) + 1;
            this.entities.Set <S_T_NodeTemplate_Detail>().Add(child);
            this.entities.SaveChanges();
            return(Json(child));
        }