Improve HtmlText module performance
This commit is contained in:
		| @ -28,16 +28,14 @@ | ||||
|     public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Edit; } } | ||||
|     public override string Title { get { return "Edit Html/Text"; } } | ||||
|  | ||||
|     HtmlTextInfo htmltext; | ||||
|     string content; | ||||
|  | ||||
|     protected override async Task OnInitializedAsync() | ||||
|     { | ||||
|         HtmlTextService htmltextservice = new HtmlTextService(http, sitestate, UriHelper); | ||||
|         List<HtmlTextInfo> htmltextlist = await htmltextservice.GetHtmlTextAsync(ModuleState.ModuleId); | ||||
|         if (htmltextlist != null) | ||||
|         HtmlTextInfo htmltext = await htmltextservice.GetHtmlTextAsync(ModuleState.ModuleId); | ||||
|         if (htmltext != null) | ||||
|         { | ||||
|             htmltext = htmltextlist.FirstOrDefault(); | ||||
|             content = htmltext.Content; | ||||
|         } | ||||
|     } | ||||
| @ -45,6 +43,7 @@ | ||||
|     private async Task SaveContent() | ||||
|     { | ||||
|         HtmlTextService htmltextservice = new HtmlTextService(http, sitestate, UriHelper); | ||||
|         HtmlTextInfo htmltext = await htmltextservice.GetHtmlTextAsync(ModuleState.ModuleId); | ||||
|         if (htmltext != null) | ||||
|         { | ||||
|             htmltext.Content = content; | ||||
|  | ||||
| @ -19,10 +19,10 @@ | ||||
|     protected override async Task OnParametersSetAsync() | ||||
|     { | ||||
|         HtmlTextService htmltextservice = new HtmlTextService(http, sitestate, UriHelper); | ||||
|         List<HtmlTextInfo> htmltext = await htmltextservice.GetHtmlTextAsync(ModuleState.ModuleId); | ||||
|         HtmlTextInfo htmltext = await htmltextservice.GetHtmlTextAsync(ModuleState.ModuleId); | ||||
|         if (htmltext != null) | ||||
|         { | ||||
|             content = htmltext.FirstOrDefault().Content; | ||||
|             content = htmltext.Content; | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @ -27,13 +27,9 @@ namespace Oqtane.Client.Modules.HtmlText.Services | ||||
|             get { return CreateApiUrl(sitestate.Alias, urihelper.GetAbsoluteUri(), "HtmlText"); } | ||||
|         } | ||||
|  | ||||
|         public async Task<List<HtmlTextInfo>> GetHtmlTextAsync(int ModuleId) | ||||
|         public async Task<HtmlTextInfo> GetHtmlTextAsync(int ModuleId) | ||||
|         { | ||||
|             List<HtmlTextInfo> htmltext = await http.GetJsonAsync<List<HtmlTextInfo>>(apiurl); | ||||
|             htmltext = htmltext | ||||
|                 .Where(item => item.ModuleId == ModuleId) | ||||
|                 .ToList(); | ||||
|             return htmltext; | ||||
|             return await http.GetJsonAsync<HtmlTextInfo>(apiurl + "/" + ModuleId.ToString()); | ||||
|         } | ||||
|  | ||||
|         public async Task AddHtmlTextAsync(HtmlTextInfo htmltext) | ||||
|  | ||||
| @ -6,7 +6,7 @@ namespace Oqtane.Client.Modules.HtmlText.Services | ||||
| { | ||||
|     public interface IHtmlTextService  | ||||
|     { | ||||
|         Task<List<HtmlTextInfo>> GetHtmlTextAsync(int ModuleId); | ||||
|         Task<HtmlTextInfo> GetHtmlTextAsync(int ModuleId); | ||||
|  | ||||
|         Task AddHtmlTextAsync(HtmlTextInfo htmltext); | ||||
|  | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Shaun Walker
					Shaun Walker