diff --git a/modules/docs/src/Volo.Docs.Application.Contracts/Volo/Docs/Projects/IProjectAppService.cs b/modules/docs/src/Volo.Docs.Application.Contracts/Volo/Docs/Projects/IProjectAppService.cs index 0866fc75e1..157ac6c842 100644 --- a/modules/docs/src/Volo.Docs.Application.Contracts/Volo/Docs/Projects/IProjectAppService.cs +++ b/modules/docs/src/Volo.Docs.Application.Contracts/Volo/Docs/Projects/IProjectAppService.cs @@ -12,6 +12,6 @@ namespace Volo.Docs.Projects Task GetByShortNameAsync(string shortName); - Task> GetVersionsAsync(Guid id); + Task> GetVersionsAsync(Guid id); } } \ No newline at end of file diff --git a/modules/docs/src/Volo.Docs.Application/Volo/Docs/Projects/ProjectAppService.cs b/modules/docs/src/Volo.Docs.Application/Volo/Docs/Projects/ProjectAppService.cs index 2c7e5265ae..2ce6f055c0 100644 --- a/modules/docs/src/Volo.Docs.Application/Volo/Docs/Projects/ProjectAppService.cs +++ b/modules/docs/src/Volo.Docs.Application/Volo/Docs/Projects/ProjectAppService.cs @@ -42,7 +42,7 @@ namespace Volo.Docs.Projects return ObjectMapper.Map(project); } - public async Task> GetVersionsAsync(Guid id) + public async Task> GetVersionsAsync(Guid id) { var project = await _projectRepository.GetAsync(id); @@ -54,8 +54,10 @@ namespace Volo.Docs.Projects SlidingExpiration = TimeSpan.FromDays(2) } ); - - return ObjectMapper.Map, List>(versions); + + return new ListResultDto( + ObjectMapper.Map, List>(versions) + ); } protected virtual async Task> GetVersionsAsync(Project project) diff --git a/modules/docs/src/Volo.Docs.Web/Models/VersionInfo.cs b/modules/docs/src/Volo.Docs.Web/Models/VersionInfoViewModel.cs similarity index 69% rename from modules/docs/src/Volo.Docs.Web/Models/VersionInfo.cs rename to modules/docs/src/Volo.Docs.Web/Models/VersionInfoViewModel.cs index 1cbe68a045..7def41b3f3 100644 --- a/modules/docs/src/Volo.Docs.Web/Models/VersionInfo.cs +++ b/modules/docs/src/Volo.Docs.Web/Models/VersionInfoViewModel.cs @@ -1,6 +1,6 @@ namespace Volo.Docs.Models { - public class VersionInfo + public class VersionInfoViewModel { public string DisplayText { get; set; } @@ -8,7 +8,7 @@ namespace Volo.Docs.Models public bool IsSelected { get; set; } - public VersionInfo(string displayText, string version, bool isSelected = false) + public VersionInfoViewModel(string displayText, string version, bool isSelected = false) { DisplayText = displayText; Version = version; diff --git a/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.cs b/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.cs index 4fa1e9892d..3aa1010c17 100644 --- a/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.cs +++ b/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.cs @@ -29,13 +29,13 @@ namespace Volo.Docs.Pages.Documents.Project public DocumentWithDetailsDto Document { get; private set; } - public List Versions { get; private set; } + public List Versions { get; private set; } public List VersionSelectItems { get; private set; } public NavigationWithDetailsDto Navigation { get; private set; } - public VersionInfo LatestVersionInfo { get; private set; } + public VersionInfoViewModel LatestVersionInfo { get; private set; } private readonly IDocumentAppService _documentAppService; private readonly IDocumentToHtmlConverterFactory _documentToHtmlConverterFactory; @@ -73,11 +73,15 @@ namespace Volo.Docs.Pages.Documents.Project private async Task SetVersionAsync() { - var versionInfoDtos = await _projectAppService.GetVersionsAsync(Project.Id); + var output = await _projectAppService.GetVersionsAsync(Project.Id); - Versions = versionInfoDtos.Select(v => new VersionInfo(v.DisplayName, v.Name)).ToList(); + Versions = output.Items + .Select(v => new VersionInfoViewModel(v.DisplayName, v.Name)) + .ToList(); - LatestVersionInfo = GetLatestVersion(); + LatestVersionInfo = Versions.First(); + LatestVersionInfo.DisplayText = $"{LatestVersionInfo.DisplayText} ({DocsAppConsts.Latest})"; + LatestVersionInfo.Version = LatestVersionInfo.Version; if (string.Equals(Version, DocsAppConsts.Latest, StringComparison.OrdinalIgnoreCase)) { @@ -128,10 +132,8 @@ namespace Volo.Docs.Pages.Documents.Project Navigation.ConvertItems(); } - - - - public string CreateLink(VersionInfo latestVersion, string version, string documentName = null) + + public string CreateLink(VersionInfoViewModel latestVersion, string version, string documentName = null) { if (latestVersion.Version == version) { @@ -148,16 +150,6 @@ namespace Volo.Docs.Pages.Documents.Project return link; } - private VersionInfo GetLatestVersion() - { - var latestVersion = Versions.First(); - - latestVersion.DisplayText = $"{latestVersion.DisplayText} ({DocsAppConsts.Latest})"; - latestVersion.Version = latestVersion.Version; - - return latestVersion; - } - public string GetSpecificVersionOrLatest() { if (Document?.Version == null) @@ -198,6 +190,7 @@ namespace Volo.Docs.Pages.Documents.Project } catch (DocumentNotFoundException) { + //TODO: Handle it! return; } @@ -211,6 +204,5 @@ namespace Volo.Docs.Pages.Documents.Project Document.Content = content; } - } } \ No newline at end of file