コード例 #1
0
        public async Task <IActionResult> TreeJson()
        {
            var records = await _resourceRepository.SearchAsync(Builders <Resource> .Filter.Empty);

            var treeNodes = BuildTreeJson(records, nameof(ManageResource));

            return(Json(new[] { treeNodes }));
        }
        public IActionResult BulidFolderTree(string parent = null)
        {
            var records = _resourceDirectoryRepository.SearchAsync(Builders <ResourceDirectory> .Filter.Empty).Result;

            var tempateTreeRoot = new TreeNode {
                id = "1", text = @"root", state = true
            };


            records.Where(item => item.Parent == null)
            .ToList()
            .ForEach(item =>
            {
                tempateTreeRoot.children.Add(RecursionBuildTempalteTreeNode(records, item));
            });

            //IMemoryCache cache = HttpContext.RequestServices.GetRequiredService<IMemoryCache>();

            //var tempateTreeRoot = new TreeNode();
            //if (string.IsNullOrEmpty(parent))
            //{
            //    var list = new List<ResourceDirectory>();
            //    tempateTreeRoot.id = "1";
            //    tempateTreeRoot.text = records[0].FolderName;
            //    tempateTreeRoot.state = true;
            //    list.Add(records[0]);
            //    cache.Set("root", list);
            //}
            //else
            //{
            //    var value = (List<ResourceDirectory>)cache.Get("root");
            //    records.ToList().ForEach(item =>
            //    {
            //        value.Add(item);

            //        cache.Set("root", value);
            //    });

            //    value.ForEach(item =>
            //    {
            //        if (item.Parent == null)
            //        {
            //            tempateTreeRoot.id = "1";
            //            tempateTreeRoot.text = item.FolderName;
            //            tempateTreeRoot.state = true;
            //        }
            //        else
            //        {
            //            tempateTreeRoot.children.Add(RecursionBuildTempalteTreeNode(value, item));

            //        }
            //    });
            //}

            return(Ok(new[] { tempateTreeRoot }));
        }
コード例 #3
0
        public async Task <IActionResult> TreeJson()
        {
            var pagedRecords = await _pageRepository.SearchAsync(Builders <Page> .Filter.Empty);

            var tempateTreeRoot = new TreeNode {
                id = "1", text = "root", state = true
            };

            foreach (var item in pagedRecords.Where(x => x.ParentPagesId == null))
            {
                tempateTreeRoot.children.Add(RecursionBuildTempalteTreeNode(item, pagedRecords));
            }

            return(Json(new[] { tempateTreeRoot }));
        }
コード例 #4
0
ファイル: HomeController.cs プロジェクト: xiaopohou/maruko
        public async Task <IActionResult> Index([FromServices] MongoDbBaseRepository <User, Guid> server)
        {
            //var user = new User()
            //{
            //    Id = Guid.NewGuid(),
            //    Name = "simple",
            //    Password = "******",
            //    Address = "重庆江北"
            //};

            //await server.InsertAsync(user);

            var user = await server.GetByIdAsync(new Guid("d06fe44f-d603-4e7b-a4cb-080fd181ab3a"));

            var userList = await server.SearchAsync(Builders <User> .Filter.Empty);

            return(View());
        }
コード例 #5
0
        public async Task <IActionResult> Index([FromServices] MongoDbBaseRepository <User, Guid> server)
        {
            //var user = new User()
            //{
            //    Id = Guid.NewGuid(),
            //    Name = "alangur",
            //    Password = "******",
            //    Address = "重庆渝中"
            //};

            //await server.InsertAsync(user);

            var user = await server.GetByIdAsync(new Guid("b787fabf-337d-4bcd-92ec-8571905c87d1"));

            var userList = await server.SearchAsync(Builders <User> .Filter.Empty);

            return(View());
        }