public async Task <IActionResult> GetNodeChilds(Guid id) { return(await Task.Run(() => { var serverApi = HttpContext.GetServerApi(); var node = serverApi.GetObjects(new[] { id }).First(); var types = HttpContext.Session.GetMetatypes(); var childIds = node.Children? .Where(x => types[x.TypeId].Children?.Any() == true) .Select(child => child.ObjectId).ToArray(); var nodeChilds = serverApi.GetObjects(childIds); var childNodes = nodeChilds .Select(x => { var mType = types[x.TypeId]; var sidePanelItem = new SidePanelItem { DObject = x, Type = mType, SubItems = x.Children.Any(y => types[y.TypeId].Children.Any()) ? new List <SidePanelItem>() : null }; return sidePanelItem.GetDynamic(id, types); }) .ToArray(); return Json(childNodes); })); }
public async Task <IActionResult> GetNodeChilds(Guid id) { return(await Task.Run(() => { dynamic[] childNodes; var context = _contextHolder.GetContext(HttpContext); var repo = context.Repository; var node = repo.GetObjects(new[] { id }).First(); var types = context.Repository.GetTypes().ToDictionary(x => x.Id, y => y); var childIds = node.Children? .Where(x => types[x.TypeId].Children?.Any() == true) .Select(child => child.ObjectId).ToArray(); var nodeChilds = repo.GetObjects(childIds); childNodes = nodeChilds.Where(t => { var mType = types[t.TypeId]; return !mType.IsService; }).Select(x => { var mType = types[x.TypeId]; var sidePanelItem = new SidePanelItem { DObject = x, Type = mType, SubItems = x.Children.Any(y => types[y.TypeId].Children.Any()) ? new List <SidePanelItem>() : null }; return sidePanelItem.GetDynamic(id, types); }) .ToArray(); return Json(childNodes); })); }