improve performance of alias handling and allow aliases to be an unlimited number of subfolders in depth

This commit is contained in:
Shaun Walker
2020-05-05 09:15:36 -04:00
parent bf84f12471
commit a02cfea6c9
54 changed files with 320 additions and 586 deletions

View File

@ -2,7 +2,6 @@
using System.Threading.Tasks;
using System.Net.Http;
using System.Linq;
using Microsoft.AspNetCore.Components;
using System.Collections.Generic;
using Oqtane.Shared;
@ -12,29 +11,23 @@ namespace Oqtane.Services
{
private readonly SiteState _siteState;
private readonly NavigationManager _navigationManager;
public ProfileService(HttpClient http, SiteState siteState, NavigationManager navigationManager) : base(http)
{
public ProfileService(HttpClient http, SiteState siteState) : base(http)
{
_siteState = siteState;
_navigationManager = navigationManager;
}
private string Apiurl
{
get { return CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "Profile"); }
}
private string Apiurl => CreateApiUrl(_siteState.Alias, "Profile");
public async Task<List<Profile>> GetProfilesAsync(int siteId)
{
List<Profile> profiles = await GetJsonAsync<List<Profile>>($"{Apiurl}?siteid={siteId.ToString()}");
List<Profile> profiles = await GetJsonAsync<List<Profile>>($"{Apiurl}?siteid={siteId}");
return profiles.OrderBy(item => item.ViewOrder).ToList();
}
public async Task<Profile> GetProfileAsync(int profileId)
{
return await GetJsonAsync<Profile>($"{Apiurl}/{profileId.ToString()}");
return await GetJsonAsync<Profile>($"{Apiurl}/{profileId}");
}
public async Task<Profile> AddProfileAsync(Profile profile)
@ -44,11 +37,11 @@ namespace Oqtane.Services
public async Task<Profile> UpdateProfileAsync(Profile profile)
{
return await PutJsonAsync<Profile>($"{Apiurl}/{profile.SiteId.ToString()}", profile);
return await PutJsonAsync<Profile>($"{Apiurl}/{profile.SiteId}", profile);
}
public async Task DeleteProfileAsync(int profileId)
{
await DeleteAsync($"{Apiurl}/{profileId.ToString()}");
await DeleteAsync($"{Apiurl}/{profileId}");
}
}
}