public void SetupViewModel(FrontendContext frontendContext, IContent node, NodeViewModel viewModel)
        {
            if (node.ContentItem.ContentType != "WikipediaPage") return;

            viewModel.name = node.As<ITitleAspect>().Title;
            viewModel.data["url"] = node.As<WikipediaPagePart>().Url;
        }
        public virtual ActionResult FetchGraph(int zoomLevel = 0)
        {
            var page = NewPage("FetchGraph");

            if (!IsAuthorized(page))
            {
                return new HttpUnauthorizedResult();
            }

            var config = page.As<IEngineConfigurationAspect>();
            var graphSettings = config.GraphSettings;

            _contentManager.UpdateEditor(page, this);

            var graph = page.As<IGraphRetrieverAspect>().RetrieveGraph().Zoom(zoomLevel, graphSettings.ZoomLevelCount).ToGraph().ToContentGraph(config.GraphDescriptor);
            var viewNodes = new Dictionary<int, NodeViewModel>(graph.VertexCount);

            foreach (var vertex in graph.Vertices)
            {
                var viewModel = new NodeViewModel { ContentItem = vertex };
                _configurationHandler.SetupViewModel(new FrontendContext(EngineContext, GraphContext), vertex, viewModel);
                viewNodes[vertex.ContentItem.Id] = viewModel;
            }

            foreach (var edge in graph.Edges)
            {
                viewNodes[edge.Source.ContentItem.Id].adjacencies.Add(edge.Target.ContentItem.Id.ToString());
                viewNodes[edge.Target.ContentItem.Id].adjacencies.Add(edge.Source.ContentItem.Id.ToString());
            }

            return Json(viewNodes.Values);
        }
        public void SetupViewModel(FrontendContext frontendContext, IContent node, NodeViewModel viewModel)
        {
            // .Has<> doesn't work here
            if (node.As<ITitleAspect>() != null) viewModel.name = node.As<ITitleAspect>().Title;

            if (node.As<IAliasAspect>() != null)
            {
                viewModel.data["url"] = new UrlHelper(_orchardServices.WorkContext.HttpContext.Request.RequestContext)
                                            .RouteUrl(_orchardServices.ContentManager.GetItemMetadata(node).DisplayRouteValues);
            }
        }