From fe59b90e5a60ab0f9a27f3e9f2050cfca3509eee Mon Sep 17 00:00:00 2001 From: Alper Ebicoglu Date: Fri, 3 Jan 2020 12:06:58 +0300 Subject: [PATCH] fixes #2538 --- .../Volo/Docs/Documents/DocumentAppService.cs | 7 ++++++- .../Pages/Documents/Project/Index.cshtml.cs | 18 +++++++++++------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/modules/docs/src/Volo.Docs.Application/Volo/Docs/Documents/DocumentAppService.cs b/modules/docs/src/Volo.Docs.Application/Volo/Docs/Documents/DocumentAppService.cs index b3b2a05b53..839c63860b 100644 --- a/modules/docs/src/Volo.Docs.Application/Volo/Docs/Documents/DocumentAppService.cs +++ b/modules/docs/src/Volo.Docs.Application/Volo/Docs/Documents/DocumentAppService.cs @@ -23,7 +23,7 @@ namespace Volo.Docs.Documents IDocumentStoreFactory documentStoreFactory, IDistributedCache documentCache, IDistributedCache languageCache, - IDistributedCache resourceCache, + IDistributedCache resourceCache, IHostEnvironment hostEnvironment) { _projectRepository = projectRepository; @@ -107,6 +107,11 @@ namespace Volo.Docs.Documents try { + if (string.IsNullOrWhiteSpace(project.ParametersDocumentName)) + { + return await Task.FromResult(null); + } + var document = await GetDocumentWithDetailsDtoAsync( project, project.ParametersDocumentName, 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 b4ba841169..7cc398ecd0 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 @@ -91,7 +91,7 @@ namespace Volo.Docs.Pages.Documents.Project try { - await SetProjectAsync(); + await SetProjectAsync(); } catch (EntityNotFoundException e) { @@ -391,7 +391,8 @@ namespace Volo.Docs.Pages.Documents.Project private async Task ConvertDocumentContentToHtmlAsync() { - await SetDocumentPreferences(); + await SetDocumentPreferencesAsync(); + SetUserPreferences(); Document.Content = await _documentSectionRenderer.RenderAsync(Document.Content, UserPreferences); @@ -431,12 +432,13 @@ namespace Volo.Docs.Pages.Documents.Project { continue; } + var key = keyValue.Split("=")[0]; var value = keyValue.Split("=")[1]; UserPreferences.Add(key, value); - UserPreferences.Add(key + "_Value", DocumentPreferences.Parameters?.FirstOrDefault(p=>p.Name == key) - ?.Values.FirstOrDefault(v=>v.Key == value).Value); + UserPreferences.Add(key + "_Value", DocumentPreferences.Parameters?.FirstOrDefault(p => p.Name == key) + ?.Values.FirstOrDefault(v => v.Key == value).Value); } } @@ -449,9 +451,11 @@ namespace Volo.Docs.Pages.Documents.Project UserPreferences.Remove(keyValue.Key); UserPreferences.Remove(keyValue.Key + "_Value"); } + UserPreferences.Add(keyValue.Key, keyValue.Value); - UserPreferences.Add(keyValue.Key + "_Value", DocumentPreferences.Parameters?.FirstOrDefault(p => p.Name == keyValue.Key) - ?.Values.FirstOrDefault(v => v.Key == keyValue.Value).Value); + UserPreferences.Add(keyValue.Key + "_Value", + DocumentPreferences.Parameters?.FirstOrDefault(p => p.Name == keyValue.Key)?.Values + .FirstOrDefault(v => v.Key == keyValue.Value).Value); } if (DocumentPreferences?.Parameters == null) @@ -469,7 +473,7 @@ namespace Volo.Docs.Pages.Documents.Project } } - public async Task SetDocumentPreferences() + public async Task SetDocumentPreferencesAsync() { var projectParameters = await _documentAppService.GetParametersAsync( new GetParametersDocumentInput