Migration to using System.Net.Http.Json; part one - functional migration
This commit is contained in:
		| @ -11,13 +11,13 @@ namespace Oqtane.Modules.HtmlText.Services | ||||
| { | ||||
|     public class HtmlTextService : ServiceBase, IHtmlTextService | ||||
|     { | ||||
|         private readonly HttpClient _http; | ||||
|          | ||||
|         private readonly NavigationManager _navigationManager; | ||||
|         private readonly SiteState _siteState; | ||||
|  | ||||
|         public HtmlTextService(HttpClient http, SiteState siteState, NavigationManager navigationManager) | ||||
|         public HtmlTextService(HttpClient http, SiteState siteState, NavigationManager navigationManager) : base(http) | ||||
|         { | ||||
|             _http = http; | ||||
|              | ||||
|             _siteState = siteState; | ||||
|             _navigationManager = navigationManager; | ||||
|         } | ||||
| @ -31,7 +31,7 @@ namespace Oqtane.Modules.HtmlText.Services | ||||
|             { | ||||
|                 //because GetJsonAsync() returns an error if no content exists for the ModuleId ( https://github.com/aspnet/AspNetCore/issues/14041 ) | ||||
|                 //null value is transfered as empty list | ||||
|                 var htmlTextList = await _http.GetJsonAsync<List<HtmlTextInfo>>(ApiUrl + "/" + moduleId + "?entityid=" + moduleId); | ||||
|                 var htmlTextList = await GetJsonAsync<List<HtmlTextInfo>>(ApiUrl + "/" + moduleId + "?entityid=" + moduleId); | ||||
|                 htmlText = htmlTextList.FirstOrDefault(); | ||||
|             } | ||||
|             catch | ||||
| @ -44,17 +44,18 @@ namespace Oqtane.Modules.HtmlText.Services | ||||
|  | ||||
|         public async Task AddHtmlTextAsync(HtmlTextInfo htmlText) | ||||
|         { | ||||
|             await _http.PostJsonAsync(ApiUrl + "?entityid=" + htmlText.ModuleId, htmlText); | ||||
|             await PostJsonAsync(ApiUrl + "?entityid=" + htmlText.ModuleId, htmlText); | ||||
|         } | ||||
|  | ||||
|         public async Task UpdateHtmlTextAsync(HtmlTextInfo htmlText) | ||||
|         { | ||||
|             await _http.PutJsonAsync(ApiUrl + "/" + htmlText.HtmlTextId + "?entityid=" + htmlText.ModuleId, htmlText); | ||||
|             await PutJsonAsync(ApiUrl + "/" + htmlText.HtmlTextId + "?entityid=" + htmlText.ModuleId, htmlText); | ||||
|         } | ||||
|  | ||||
|  | ||||
|         public async Task DeleteHtmlTextAsync(int moduleId) | ||||
|         { | ||||
|             await _http.DeleteAsync(ApiUrl + "/" + moduleId + "?entityid=" + moduleId); | ||||
|             await DeleteAsync(ApiUrl + "/" + moduleId + "?entityid=" + moduleId); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Pavel Vesely
					Pavel Vesely