Esempio n. 1
0
 public void CreateNewNode(EditNodeModel model)
 {
     var node = new Node();
     node.Name = model.FormData.Name;
     node.Code = model.FormData.Code;
     if (_nodeRepository.IsNodeCodeRepeatInUnit(NpcContext.CurrentUser.Unit.Id, node.Code, null))
     {
         throw new ApplicationException("节点编码不能重复,请重新设置!");
     }
     if (model.ParentId.HasValue)
     {
         node.ParentNode = _nodeRepository.Find(model.ParentId.Value);
     }
     node.OrderSort = model.FormData.OrderSort;
     node.Unit = NpcContext.CurrentUser.Unit;
     node.RecordDescription.CreateBy(NpcContext.CurrentUser);
     _nodeRepository.Save(node);
 }
Esempio n. 2
0
        private NodeTreeModelComponent ConvertArticleCategoryToModel(Node node, bool isNeedSub)
        {
            var model = new NodeTreeModelComponent()
            {
                Id = node.Id,
                Name = node.Name,
                CategoryId = node.OuterCategoryId,
                Code = node.Code,
                CategoryName = node.OuterCategoryId.HasValue ? _articleCategoryRepository.Find(node.OuterCategoryId.Value).CategoryName : "",
                IconCls = ApplicationConst.TreeLeafCls,
                NodeRecordMark = node.NodeRecordMark,
                OrderSort = node.OrderSort
            };
            var childrens = _nodeRepository.GetSubs(node.Id).ToList();
            if (childrens.Any())
            {
                if (isNeedSub)
                {
                    childrens.ForEach(o => model.Childrens.Add(ConvertArticleCategoryToModel(o, true)));
                }
                model.IconCls = ApplicationConst.TreeParentNode;
                model.State = isNeedSub ? "open" : "closed";
            }

            return model;
        }
Esempio n. 3
0
 private static void WapperNodeRecordMark(Node node)
 {
     if (node.NodeRecordMark == null)
     {
         node.NodeRecordMark = new NodeRecordMark();
     }
     if (string.IsNullOrEmpty(node.NodeRecordMark.FirstContentTitle))
     {
         node.NodeRecordMark.FirstContentTitle = "内容一";
     }
     if (string.IsNullOrEmpty(node.NodeRecordMark.FirstImageTitle))
     {
         node.NodeRecordMark.FirstImageTitle = "图片一";
     }
     if (string.IsNullOrEmpty(node.NodeRecordMark.FisrtTitleTitle))
     {
         node.NodeRecordMark.FisrtTitleTitle = "标题一";
     }
     if (string.IsNullOrEmpty(node.NodeRecordMark.RecordLinkTitle))
     {
         node.NodeRecordMark.RecordLinkTitle = "链接";
     }
     if (string.IsNullOrEmpty(node.NodeRecordMark.SecondContentTitle))
     {
         node.NodeRecordMark.SecondContentTitle = "内容二";
     }
     if (string.IsNullOrEmpty(node.NodeRecordMark.SecondImageTitle))
     {
         node.NodeRecordMark.SecondImageTitle = "图片二";
     }
     if (string.IsNullOrEmpty(node.NodeRecordMark.SecondTitleTitle))
     {
         node.NodeRecordMark.SecondTitleTitle = "标题二";
     }
 }