Client fixes
Client is partially done. 227 warnings left out of 1500 I like Rider
This commit is contained in:
@ -23,33 +23,33 @@ namespace Oqtane.Services
|
||||
_navigationManager = navigationManager;
|
||||
}
|
||||
|
||||
private string apiurl
|
||||
private string Apiurl
|
||||
{
|
||||
get { return CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "Page"); }
|
||||
}
|
||||
|
||||
public async Task<List<Page>> GetPagesAsync(int SiteId)
|
||||
public async Task<List<Page>> GetPagesAsync(int siteId)
|
||||
{
|
||||
List<Page> pages = await _http.GetJsonAsync<List<Page>>(apiurl + "?siteid=" + SiteId.ToString());
|
||||
List<Page> pages = await _http.GetJsonAsync<List<Page>>(Apiurl + "?siteid=" + siteId.ToString());
|
||||
pages = GetPagesHierarchy(pages);
|
||||
return pages;
|
||||
}
|
||||
|
||||
public async Task<Page> GetPageAsync(int PageId)
|
||||
public async Task<Page> GetPageAsync(int pageId)
|
||||
{
|
||||
return await _http.GetJsonAsync<Page>(apiurl + "/" + PageId.ToString());
|
||||
return await _http.GetJsonAsync<Page>(Apiurl + "/" + pageId.ToString());
|
||||
}
|
||||
|
||||
public async Task<Page> GetPageAsync(int PageId, int UserId)
|
||||
public async Task<Page> GetPageAsync(int pageId, int userId)
|
||||
{
|
||||
return await _http.GetJsonAsync<Page>(apiurl + "/" + PageId.ToString() + "?userid=" + UserId.ToString());
|
||||
return await _http.GetJsonAsync<Page>(Apiurl + "/" + pageId.ToString() + "?userid=" + userId.ToString());
|
||||
}
|
||||
|
||||
public async Task<Page> GetPageAsync(string Path, int SiteId)
|
||||
public async Task<Page> GetPageAsync(string path, int siteId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await _http.GetJsonAsync<Page>(apiurl + "/path/" + SiteId.ToString() + "?path=" + WebUtility.UrlEncode(Path));
|
||||
return await _http.GetJsonAsync<Page>(Apiurl + "/path/" + siteId.ToString() + "?path=" + WebUtility.UrlEncode(path));
|
||||
}
|
||||
catch
|
||||
{
|
||||
@ -57,62 +57,62 @@ namespace Oqtane.Services
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<Page> AddPageAsync(Page Page)
|
||||
public async Task<Page> AddPageAsync(Page page)
|
||||
{
|
||||
return await _http.PostJsonAsync<Page>(apiurl, Page);
|
||||
return await _http.PostJsonAsync<Page>(Apiurl, page);
|
||||
}
|
||||
|
||||
public async Task<Page> AddPageAsync(int PageId, int UserId)
|
||||
public async Task<Page> AddPageAsync(int pageId, int userId)
|
||||
{
|
||||
return await _http.PostJsonAsync<Page>(apiurl + "/" + PageId.ToString() + "?userid=" + UserId.ToString(), null);
|
||||
return await _http.PostJsonAsync<Page>(Apiurl + "/" + pageId.ToString() + "?userid=" + userId.ToString(), null);
|
||||
}
|
||||
|
||||
public async Task<Page> UpdatePageAsync(Page Page)
|
||||
public async Task<Page> UpdatePageAsync(Page page)
|
||||
{
|
||||
return await _http.PutJsonAsync<Page>(apiurl + "/" + Page.PageId.ToString(), Page);
|
||||
return await _http.PutJsonAsync<Page>(Apiurl + "/" + page.PageId.ToString(), page);
|
||||
}
|
||||
|
||||
public async Task UpdatePageOrderAsync(int SiteId, int PageId, int? ParentId)
|
||||
public async Task UpdatePageOrderAsync(int siteId, int pageId, int? parentId)
|
||||
{
|
||||
await _http.PutJsonAsync(apiurl + "/?siteid=" + SiteId.ToString() + "&pageid=" + PageId.ToString() + "&parentid=" + ((ParentId == null) ? "" : ParentId.ToString()), null);
|
||||
await _http.PutJsonAsync(Apiurl + "/?siteid=" + siteId.ToString() + "&pageid=" + pageId.ToString() + "&parentid=" + ((parentId == null) ? "" : parentId.ToString()), null);
|
||||
}
|
||||
|
||||
public async Task DeletePageAsync(int PageId)
|
||||
public async Task DeletePageAsync(int pageId)
|
||||
{
|
||||
await _http.DeleteAsync(apiurl + "/" + PageId.ToString());
|
||||
await _http.DeleteAsync(Apiurl + "/" + pageId.ToString());
|
||||
}
|
||||
|
||||
private static List<Page> GetPagesHierarchy(List<Page> Pages)
|
||||
private static List<Page> GetPagesHierarchy(List<Page> pages)
|
||||
{
|
||||
List<Page> hierarchy = new List<Page>();
|
||||
Action<List<Page>, Page> GetPath = null;
|
||||
GetPath = (List<Page> pages, Page page) =>
|
||||
Action<List<Page>, Page> getPath = null;
|
||||
getPath = (pageList, page) =>
|
||||
{
|
||||
IEnumerable<Page> children;
|
||||
int level;
|
||||
if (page == null)
|
||||
{
|
||||
level = -1;
|
||||
children = Pages.Where(item => item.ParentId == null);
|
||||
children = pages.Where(item => item.ParentId == null);
|
||||
}
|
||||
else
|
||||
{
|
||||
level = page.Level;
|
||||
children = Pages.Where(item => item.ParentId == page.PageId);
|
||||
children = pages.Where(item => item.ParentId == page.PageId);
|
||||
}
|
||||
foreach (Page child in children)
|
||||
{
|
||||
child.Level = level + 1;
|
||||
child.HasChildren = Pages.Where(item => item.ParentId == child.PageId).Any();
|
||||
child.HasChildren = pages.Any(item => item.ParentId == child.PageId);
|
||||
hierarchy.Add(child);
|
||||
GetPath(pages, child);
|
||||
getPath(pageList, child);
|
||||
}
|
||||
};
|
||||
Pages = Pages.OrderBy(item => item.Order).ToList();
|
||||
GetPath(Pages, null);
|
||||
pages = pages.OrderBy(item => item.Order).ToList();
|
||||
getPath(pages, null);
|
||||
|
||||
// add any non-hierarchical items to the end of the list
|
||||
foreach (Page page in Pages)
|
||||
foreach (Page page in pages)
|
||||
{
|
||||
if (hierarchy.Find(item => item.PageId == page.PageId) == null)
|
||||
{
|
||||
|
Reference in New Issue
Block a user