예제 #1
0
        public virtual async Task <NavigationNode> GetNavigationAsync(GetNavigationDocumentInput input)
        {
            var project = await _projectRepository.GetAsync(input.ProjectId);

            var navigationDocument = await GetDocumentWithDetailsDtoAsync(
                project,
                project.NavigationDocumentName,
                input.LanguageCode,
                input.Version
                );

            if (!JsonConvertExtensions.TryDeserializeObject <NavigationNode>(navigationDocument.Content, out var navigationNode))
            {
                throw new UserFriendlyException($"Cannot validate navigation file '{project.NavigationDocumentName}' for the project {project.Name}.");
            }

            var leafs = navigationNode.Items.GetAllNodes(x => x.Items)
                        .Where(x => !x.Path.IsNullOrWhiteSpace())
                        .ToList();

            foreach (var leaf in leafs)
            {
                var cacheKey           = CacheKeyGenerator.GenerateDocumentUpdateInfoCacheKey(project, leaf.Path, input.LanguageCode, input.Version);
                var documentUpdateInfo = await DocumentUpdateCache.GetAsync(cacheKey);

                if (documentUpdateInfo != null)
                {
                    leaf.CreationTime              = documentUpdateInfo.CreationTime;
                    leaf.LastUpdatedTime           = documentUpdateInfo.LastUpdatedTime;
                    leaf.LastSignificantUpdateTime = documentUpdateInfo.LastSignificantUpdateTime;
                }
            }

            return(navigationNode);
        }
예제 #2
0
 public Task <NavigationNode> GetNavigationAsync(GetNavigationDocumentInput input)
 {
     return(DocumentAppService.GetNavigationAsync(input));
 }