public virtual ActionResult SubMenu(string parentUrl) { var menuItems = new List <MenuItemViewModel>(); using (var api = ApiFactory.Create()) { var pageRequest = new PageExistsRequest { PageUrl = parentUrl }; var pageResponse = api.Pages.Page.Exists(pageRequest); var sitemapId = GetSitemapId(api); if (sitemapId.HasValue) { var parentRequest = new GetSitemapNodesRequest(); parentRequest.SitemapId = sitemapId.Value; parentRequest.Data.Take = 1; parentRequest.Data.Filter.Add("ParentId", null); var filter = new DataFilter(FilterConnector.Or); parentRequest.Data.Filter.Inner.Add(filter); filter.Add("Url", parentUrl); if (pageResponse.Data.Exists) { filter.Add("PageId", pageResponse.Data.PageId.Value); } parentRequest.Data.Order.Add("DisplayOrder"); var parentResponse = api.Pages.Sitemap.Nodes.Get(parentRequest); if (parentResponse.Data.Items.Count == 1) { var request = new GetSitemapTreeRequest { SitemapId = sitemapId.Value }; request.Data.NodeId = parentResponse.Data.Items[0].Id; var response = api.Pages.Sitemap.Tree.Get(request); if (response.Data.Count > 0) { menuItems = response.Data.Select(mi => new MenuItemViewModel { Caption = mi.Title, Url = mi.Url }).ToList(); menuItems.Insert(0, new MenuItemViewModel { Caption = "Main", Url = parentUrl }); } } } } return(View(menuItems)); }
public PageExistsResponse Get(PageExistsRequest request) { var url = urlService.FixUrl(request.PageUrl); var id = repository .AsQueryable<Module.Root.Models.Page>(p => p.PageUrlHash == url.UrlHash()) .Select(p => p.Id) .FirstOrDefault(); return new PageExistsResponse { Data = new PageModel { Exists = !id.HasDefaultValue(), PageId = !id.HasDefaultValue() ? id : (System.Guid?)null } }; }
public virtual ActionResult SubMenu(string parentUrl) { var menuItems = new List<MenuItemViewModel>(); using (var api = ApiFactory.Create()) { var pageRequest = new PageExistsRequest { PageUrl = parentUrl }; var pageResponse = api.Pages.Page.Exists(pageRequest); var sitemapId = GetSitemapId(api); if (sitemapId.HasValue) { var parentRequest = new GetSitemapNodesRequest(); parentRequest.SitemapId = sitemapId.Value; parentRequest.Data.Take = 1; parentRequest.Data.Filter.Add("ParentId", null); var filter = new DataFilter(FilterConnector.Or); parentRequest.Data.Filter.Inner.Add(filter); filter.Add("Url", parentUrl); if (pageResponse.Data.Exists) { filter.Add("PageId", pageResponse.Data.PageId.Value); } parentRequest.Data.Order.Add("DisplayOrder"); var parentResponse = api.Pages.Sitemap.Nodes.Get(parentRequest); if (parentResponse.Data.Items.Count == 1) { var request = new GetSitemapTreeRequest { SitemapId = sitemapId.Value }; request.Data.NodeId = parentResponse.Data.Items[0].Id; var response = api.Pages.Sitemap.Tree.Get(request); if (response.Data.Count > 0) { menuItems = response.Data.Select(mi => new MenuItemViewModel { Caption = mi.Title, Url = mi.Url }).ToList(); menuItems.Insert(0, new MenuItemViewModel { Caption = "Main", Url = parentUrl }); } } } } return View(menuItems); }
/// <summary> /// Exists the specified request. /// </summary> /// <param name="request">The request.</param> /// <returns><c>PageExistsResponse</c> with page data.</returns> PageExistsResponse IPageService.Exists(PageExistsRequest request) { return(pageExistsService.Get(request)); }
/// <summary> /// Exists the specified request. /// </summary> /// <param name="request">The request.</param> /// <returns><c>PageExistsResponse</c> with page data.</returns> PageExistsResponse IPageService.Exists(PageExistsRequest request) { return pageExistsService.Get(request); }