public async Task <IViewComponentResult> InvokeAsync(Models.ContentNode node) { // display mode would have been set in the starting context var treeContext = ViewContext.ViewData.GetTreeContext(); // TODO: Update all widgets so can be exported / imported properly await _contentManager.EnsureContentNodeModel(node); // Update current node id for decendent nodes ViewContext.ViewData.UpdateTreeContext(node.Id); return(View("/UI/Views/Rendering/ContentNode.cshtml", node)); }
private async Task <Models.ContentNode> CreateNodeFromDefaultModel(string treeId, string containerName, string widgetType, string modelName, string viewId) { var widgetConfig = _widgetProvider.GetWidgetConfig(widgetType); IWidgetModel widgetModel; // Create an instance of the widget using based on default or named model if (string.IsNullOrEmpty(modelName)) { widgetModel = _widgetProvider.Create(widgetType); } else { widgetModel = _widgetProvider.Create(widgetType, modelName); } // Map the widget to the ContentTree var node = new Models.ContentNode() { ContentTreeId = treeId, WidgetType = widgetType, WidgetId = widgetModel?.Id, Zone = containerName }; // Verify ViewId if (viewId == null || !widgetConfig.Views.Any(x => x.Id == viewId)) { node.ViewId = widgetConfig.GetDefaultViewId(); } else { node.ViewId = viewId; } await _contentManager.CreateContentNode(node); return(node); }