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

@ -43,7 +43,7 @@
{
try
{
[Module]Service = new [Module]Service(http, sitestate, NavigationManager);
[Module]Service = new [Module]Service(http, sitestate);
if (PageState.Action == "Edit")
{
_id = Int32.Parse(PageState.QueryString["id"]);

View File

@ -78,7 +78,7 @@ else
{
try
{
[Module]Service = new [Module]Service(http, sitestate, NavigationManager);
[Module]Service = new [Module]Service(http, sitestate);
_[Module]s = await [Module]Service.Get[Module]sAsync(ModuleState.ModuleId);
}
catch (Exception ex)

View File

@ -2,7 +2,6 @@ using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components;
using Oqtane.Modules;
using Oqtane.Services;
using Oqtane.Shared;
@ -12,44 +11,39 @@ namespace [Owner].[Module]s.Services
{
public class [Module]Service : ServiceBase, I[Module]Service, IService
{
private readonly NavigationManager _navigationManager;
private readonly SiteState _siteState;
public [Module]Service(HttpClient http, SiteState siteState, NavigationManager navigationManager) : base(http)
public [Module]Service(HttpClient http, SiteState siteState) : base(http)
{
_siteState = siteState;
_navigationManager = navigationManager;
}
private string Apiurl
{
get { return CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "[Module]"); }
}
private string Apiurl=> CreateApiUrl(_siteState.Alias, "[Module]");
public async Task<List<[Module]>> Get[Module]sAsync(int ModuleId)
{
List<[Module]> [Module]s = await GetJsonAsync<List<[Module]>>(Apiurl + "?moduleid=" + ModuleId.ToString());
List<[Module]> [Module]s = await GetJsonAsync<List<[Module]>>($"{Apiurl}?moduleid={ModuleId}");
return [Module]s.OrderBy(item => item.Name).ToList();
}
public async Task<[Module]> Get[Module]Async(int [Module]Id)
{
return await GetJsonAsync<[Module]>(Apiurl + "/" + [Module]Id.ToString());
return await GetJsonAsync<[Module]>($"{Apiurl}/{[Module]Id}");
}
public async Task<[Module]> Add[Module]Async([Module] [Module])
{
return await PostJsonAsync<[Module]>(Apiurl + "?entityid=" + [Module].ModuleId, [Module]);
return await PostJsonAsync<[Module]>($"{Apiurl}?entityid={[Module].ModuleId}", [Module]);
}
public async Task<[Module]> Update[Module]Async([Module] [Module])
{
return await PutJsonAsync<[Module]>(Apiurl + "/" + [Module].[Module]Id + "?entityid=" + [Module].ModuleId, [Module]);
return await PutJsonAsync<[Module]>($"{Apiurl}/{[Module].[Module]Id}?entityid={[Module].ModuleId}", [Module]);
}
public async Task Delete[Module]Async(int [Module]Id)
{
await DeleteAsync(Apiurl + "/" + [Module]Id.ToString());
await DeleteAsync($"{Apiurl}/{[Module]Id}");
}
}
}