Ejemplo n.º 1
0
        public GetSitemapTreeResponse Get(GetSitemapTreeRequest request)
        {
            var allNodes = repository
                           .AsQueryable <Module.Pages.Models.SitemapNode>()
                           .OrderBy(node => node.Title)
                           .Select(node => new SitemapTreeNodeModel
            {
                Id             = node.Id,
                Version        = node.Version,
                CreatedBy      = node.CreatedByUser,
                CreatedOn      = node.CreatedOn,
                LastModifiedBy = node.ModifiedByUser,
                LastModifiedOn = node.ModifiedOn,

                ParentId     = node.ParentNode != null && !node.ParentNode.IsDeleted ? node.ParentNode.Id : (System.Guid?)null,
                Title        = node.Title,
                Url          = node.Url,
                DisplayOrder = node.DisplayOrder
            })
                           .ToList();

            return(new GetSitemapTreeResponse {
                Data = GetChildren(allNodes, request.Data.NodeId)
            });
        }
Ejemplo n.º 2
0
        public GetSitemapTreeResponse Get(GetSitemapTreeRequest request)
        {
            var pagesToFuture        = SitemapHelper.GetPagesToFuture(cmsConfiguration.EnableMultilanguage, repository);
            var translationsToFuture = cmsConfiguration.EnableMultilanguage && request.Data.LanguageId.HasValue
                                           ? repository.AsQueryable <Module.Pages.Models.SitemapNodeTranslation>()
                                       .Where(t => t.Node.Sitemap.Id == request.SitemapId && t.Language.Id == request.Data.LanguageId.Value && !t.IsDeleted && !t.Node.IsDeleted)
                                       .Select(t => new SitemapTreeNodeTranslationModel
            {
                Id             = t.Id,
                Version        = t.Version,
                CreatedBy      = t.CreatedByUser,
                CreatedOn      = t.CreatedOn,
                LastModifiedBy = t.ModifiedByUser,
                LastModifiedOn = t.ModifiedOn,

                NodeId     = t.Node.Id,
                LanguageId = t.Language.Id,
                Title      = t.Title,
                Url        = t.Url,
                UsePageTitleAsNodeTitle = t.UsePageTitleAsNodeTitle,
                Macro = t.Macro
            })
                                       .ToFuture()
                                           : null;

            var allNodes = repository
                           .AsQueryable <Module.Pages.Models.SitemapNode>()
                           .Where(node => node.Sitemap.Id == request.SitemapId && !node.IsDeleted)
                           .OrderBy(node => node.DisplayOrder)
                           .Select(node => new SitemapTreeNodeModel
            {
                Id             = node.Id,
                Version        = node.Version,
                CreatedBy      = node.CreatedByUser,
                CreatedOn      = node.CreatedOn,
                LastModifiedBy = node.ModifiedByUser,
                LastModifiedOn = node.ModifiedOn,

                ParentId                = node.ParentNode != null && !node.ParentNode.IsDeleted ? node.ParentNode.Id : (Guid?)null,
                Title                   = node.Page != null && node.UsePageTitleAsNodeTitle ? node.Page.Title : node.Title,
                Url                     = node.Page != null ? node.Page.PageUrl : node.Url,
                PageId                  = node.Page != null ? node.Page.Id : (Guid?)null,
                PageIsPublished         = node.Page != null && !node.Page.IsDeleted && node.Page.Status == PageStatus.Published,
                UsePageTitleAsNodeTitle = node.UsePageTitleAsNodeTitle,
                DisplayOrder            = node.DisplayOrder,
                Macro                   = node.Macro
            })
                           .ToFuture()
                           .ToList();

            var nodes = GetChildren(allNodes, request.Data.NodeId);

            if (pagesToFuture != null && translationsToFuture != null)
            {
                Translate(nodes, request.Data.LanguageId, translationsToFuture.ToList(), pagesToFuture.ToList());
            }

            return(new GetSitemapTreeResponse {
                Data = nodes
            });
        }