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 ProfileService : ServiceBase, IProfileService
{
private readonly HttpClient _http;
private readonly SiteState _siteState;
private readonly NavigationManager _navigationManager;
public ProfileService(HttpClient http, SiteState siteState, NavigationManager navigationManager)
public ProfileService(HttpClient http, SiteState siteState, NavigationManager navigationManager) : base(http)
{
_http = http;
_siteState = siteState;
_navigationManager = navigationManager;
}
@ -28,27 +28,27 @@ namespace Oqtane.Services
public async Task<List<Profile>> GetProfilesAsync(int siteId)
{
List<Profile> profiles = await _http.GetJsonAsync<List<Profile>>($"{Apiurl}?siteid={siteId.ToString()}");
List<Profile> profiles = await GetJsonAsync<List<Profile>>($"{Apiurl}?siteid={siteId.ToString()}");
return profiles.OrderBy(item => item.ViewOrder).ToList();
}
public async Task<Profile> GetProfileAsync(int profileId)
{
return await _http.GetJsonAsync<Profile>($"{Apiurl}/{profileId.ToString()}");
return await GetJsonAsync<Profile>($"{Apiurl}/{profileId.ToString()}");
}
public async Task<Profile> AddProfileAsync(Profile profile)
{
return await _http.PostJsonAsync<Profile>(Apiurl, profile);
return await PostJsonAsync<Profile>(Apiurl, profile);
}
public async Task<Profile> UpdateProfileAsync(Profile profile)
{
return await _http.PutJsonAsync<Profile>($"{Apiurl}/{profile.SiteId.ToString()}", profile);
return await PutJsonAsync<Profile>($"{Apiurl}/{profile.SiteId.ToString()}", profile);
}
public async Task DeleteProfileAsync(int profileId)
{
await _http.DeleteAsync($"{Apiurl}/{profileId.ToString()}");
await DeleteAsync($"{Apiurl}/{profileId.ToString()}");
}
}
}