Migration to using System.Net.Http.Json; part one - functional migration

This commit is contained in:
Pavel Vesely
2020-04-15 23:03:37 +02:00
parent fe2ad29b3b
commit 95e9bee4e2
29 changed files with 293 additions and 215 deletions

View File

@ -12,13 +12,13 @@ namespace Oqtane.Services
{
public class LogService : ServiceBase, ILogService
{
private readonly HttpClient _http;
private readonly SiteState _siteState;
private readonly NavigationManager _navigationManager;
public LogService(HttpClient http, SiteState siteState, NavigationManager navigationManager)
public LogService(HttpClient http, SiteState siteState, NavigationManager navigationManager) : base(http)
{
_http = http;
_siteState = siteState;
_navigationManager = navigationManager;
}
@ -30,12 +30,12 @@ namespace Oqtane.Services
public async Task<List<Log>> GetLogsAsync(int siteId, string level, string function, int rows)
{
return await _http.GetJsonAsync<List<Log>>($"{Apiurl}?siteid={siteId.ToString()}&level={level}&function={function}&rows={rows.ToString()}");
return await GetJsonAsync<List<Log>>($"{Apiurl}?siteid={siteId.ToString()}&level={level}&function={function}&rows={rows.ToString()}");
}
public async Task<Log> GetLogAsync(int logId)
{
return await _http.GetJsonAsync<Log>($"{Apiurl}/{logId.ToString()}");
return await GetJsonAsync<Log>($"{Apiurl}/{logId.ToString()}");
}
public async Task Log(int? pageId, int? moduleId, int? userId, string category, string feature, LogFunction function, LogLevel level, Exception exception, string message, params object[] args)
@ -69,7 +69,7 @@ namespace Oqtane.Services
log.Message = message;
log.MessageTemplate = "";
log.Properties = JsonSerializer.Serialize(args);
await _http.PostJsonAsync(CreateCrossTenantUrl(Apiurl, alias), log);
await PostJsonAsync(CreateCrossTenantUrl(Apiurl, alias), log);
}
}
}