Example #1
0
 public async Task<List<TreeSelectViewModel>> GetTreeSelectViewModel()
 {
     var viewModelList = new List<TreeSelectViewModel>();
     var list = await _repository.FindListByClauseAsync(s => s.EnabledMark == true && s.DeleteMark == false);
     list.Where(s => s.ParentId == "0").ToList().ForEach(item =>
     {
         var viewModel = new TreeSelectViewModel
         {
             id = item.Id,
             name = item.FullName
         };
         GetItemsEntityByParentId(item.Id, viewModel, list);
         viewModelList.Add(viewModel);
     });
     return viewModelList;
 }
Example #2
0
 private TreeSelectViewModel GetItemsEntityByParentId(string parendId, TreeSelectViewModel viewModel, IEnumerable<ItemsEntity> list)
 {
     var items = list.Where(s => s.ParentId.Equals(parendId));
     if (!items.Any()) return null;
     List<TreeSelectViewModel> layuiTreeViewModelsList = new List<TreeSelectViewModel>();
     items.ToList().ForEach(item =>
     {
         TreeSelectViewModel layuiTreeViewModel = new TreeSelectViewModel
         {
             id = item.Id,
             name = item.FullName
         };
         GetItemsEntityByParentId(item.Id, layuiTreeViewModel, list);
         layuiTreeViewModelsList.Add(layuiTreeViewModel);
     });
     viewModel.children = layuiTreeViewModelsList;
     return viewModel;
 }