public IActionResult Index(string contentitemid = "/", string type = "root") { //if (!Services.Authorizer.Authorize(StandardPermissions.AccessAdminPanel, // T("Not allowed to access admin panel"))) // return new HttpUnauthorizedResult(); var node = GetTreeNode(contentitemid, type) ?? new TreeNode { Id = "/", Type = "root", Title = "Root" }; //https://stackoverflow.com/questions/33495617/how-to-use-async-lambda-with-selectmany var children = _treeNodeProviders.Select(async p => await p.GetChildren(type, contentitemid)).SelectMany(task => task.Result); // var children = _treeNodeProviders.SelectMany( p => p.GetChildren(type, contentitemid )).ToList(); // var children = _treeNodeProviders.Select(x=> x).SelectMany(p => p.GetChildren(type, id).Result); // var children = await _treeNodeProviders.SelectMany(p => p.GetChildren(type, id)); var model = new TreeExplorerViewModel { Node = node, Children = children }; if (Request.IsAjaxRequest()) { return(new JsonResult(new { Data = model })); } return(View(model)); }
public ActionResult Index(string id = "/", string type = "root") { if (!Services.Authorizer.Authorize(StandardPermissions.AccessAdminPanel, T("Not allowed to access admin panel"))) { return(new HttpUnauthorizedResult()); } var node = GetTreeNode(id, type) ?? new TreeNode { Id = "/", Type = "root", Title = T("Root").Text }; var children = _treeNodeProviders .SelectMany(p => p.GetChildren(type, id)); var model = new TreeExplorerViewModel { Node = node, Children = children }; if (Request.IsAjaxRequest()) { return(new JsonResult { Data = model }); } return(View(model)); }
public ProjectsTreeControlView() { // Inicializa los componentes InitializeComponent(); // Inicializa el formulario trvExplorer.DataContext = ViewModel = new TreeExplorerViewModel(); trvExplorer.ItemsSource = ViewModel.Nodes; FormView = new BaseFormView(ViewModel); }