Ejemplo n.º 1
0
        public async Task <IEnumerable <SitemapNode> > FindByName(string name)
        {
            var nodes = await _sitemapNodeRepository.GetListAsync(new Queries.SitemapNodeQuery
            {
                Name = name
            });

            return(new List <SitemapNode>(nodes));
        }
Ejemplo n.º 2
0
        internal async Task <IEnumerable <MenuNodeDto> > InternalBuildAsync()
        {
            _logger.LogDebug("The reconstruction of the sitemap was started...");

            var nodes = await _sitemapNodeRepository.GetListAsync(new Queries.SitemapNodeQuery
            {
                NodeType = Models.NodeType.Menu
            });

            _memoryCache.Remove(MENU_PROVIDER_CACHE_INDEX_NAME);

            var mapNodes = nodes.Select(x => new Dto.MenuNodeDto
            {
                Id       = x.Id,
                ParentId = x.ParentId,
                Title    = x.Name,
                Path     = x.Path,
                Icon     = x.Icon
            }).ToList();

            //Index all node
            var indexSitemap = new Dictionary <Guid, MenuNodeDto>();

            foreach (var node in mapNodes)
            {
                indexSitemap.Add(node.Id, node);
            }
            _memoryCache.Set(MENU_PROVIDER_CACHE_INDEX_NAME, indexSitemap);

            var rootNodes = mapNodes.Where(x => x.ParentId == null);

            foreach (var node in rootNodes)
            {
                SetChildren(node, mapNodes);
            }

            _logger.LogDebug("The reconstruction of the sitemap has been completed");

            return(rootNodes);
        }