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

@ -10,13 +10,13 @@ namespace Oqtane.Services
{
public class TenantService : ServiceBase, ITenantService
{
private readonly HttpClient _http;
private readonly SiteState _siteState;
private readonly NavigationManager _navigationManager;
public TenantService(HttpClient http, SiteState siteState, NavigationManager navigationManager)
public TenantService(HttpClient http, SiteState siteState, NavigationManager navigationManager) : base(http)
{
_http = http;
_siteState = siteState;
_navigationManager = navigationManager;
}
@ -28,28 +28,28 @@ namespace Oqtane.Services
public async Task<List<Tenant>> GetTenantsAsync()
{
List<Tenant> tenants = await _http.GetJsonAsync<List<Tenant>>(Apiurl);
List<Tenant> tenants = await GetJsonAsync<List<Tenant>>(Apiurl);
return tenants.OrderBy(item => item.Name).ToList();
}
public async Task<Tenant> GetTenantAsync(int tenantId)
{
return await _http.GetJsonAsync<Tenant>($"{Apiurl}/{tenantId.ToString()}");
return await GetJsonAsync<Tenant>($"{Apiurl}/{tenantId.ToString()}");
}
public async Task<Tenant> AddTenantAsync(Tenant tenant)
{
return await _http.PostJsonAsync<Tenant>(Apiurl, tenant);
return await PostJsonAsync<Tenant>(Apiurl, tenant);
}
public async Task<Tenant> UpdateTenantAsync(Tenant tenant)
{
return await _http.PutJsonAsync<Tenant>($"{Apiurl}/{tenant.TenantId.ToString()}", tenant);
return await PutJsonAsync<Tenant>($"{Apiurl}/{tenant.TenantId.ToString()}", tenant);
}
public async Task DeleteTenantAsync(int tenantId)
{
await _http.DeleteAsync($"{Apiurl}/{tenantId.ToString()}");
await DeleteAsync($"{Apiurl}/{tenantId.ToString()}");
}
}
}