예제 #1
0
        public List <T_ParentSysListModel> ParentNode(List <T_SysListModel> node, int?parentId)
        {
            List <T_ParentSysListModel> newnode = new List <T_ParentSysListModel>();

            var parent = node.Where(w => w.Id == parentId).OrderBy(b => b.Listorder).ToList();

            if (parent.Count() > 0)
            {
                foreach (var item in parent)
                {
                    T_ParentSysListModel data = new T_ParentSysListModel();
                    data.Id       = item.Id;
                    data.Name     = item.Name;
                    data.ParentId = item.ParentId;
                    if (item.ParentId != null && node.Count(w => w.Id == item.ParentId) > 0)
                    {
                        data.Parent = ParentNode(node, item.ParentId);
                    }

                    newnode.Add(data);
                }
            }

            return(newnode);
        }
예제 #2
0
        public List <T_ParentSysListModel> ParentList(int Id)
        {
            List <T_ParentSysListModel> result = new List <T_ParentSysListModel>();
            T_ParentSysListModel        data   = new T_ParentSysListModel();

            List <T_SysListModel> list = new List <T_SysListModel>();
            var SysId = dal.Filter(o => o.Id == Id).FirstOrDefault().SysId;

            list = dal.Filter(o => o.SysId == SysId).OrderBy(b => b.Listorder).DTOList().ToList();

            foreach (var item in list.Where(w => w.Id == Id))
            {
                data          = new T_ParentSysListModel();
                data.Id       = item.Id;
                data.Name     = item.Name;
                data.ParentId = item.ParentId;
                if (item.ParentId != null && list.Count(w => w.Id == item.ParentId) > 0)
                {
                    data.Parent = ParentNode(list, item.ParentId);
                }
                result.Add(data);
            }
            return(result);
        }