Use string Interpolation for constructing Urls (#324)
This commit is contained in:
@ -30,26 +30,26 @@ namespace Oqtane.Services
|
||||
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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
|
||||
{
|
||||
@ -64,22 +64,25 @@ namespace Oqtane.Services
|
||||
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
await _http.PutJsonAsync(Apiurl + "/?siteid=" + siteId.ToString() + "&pageid=" + pageId.ToString() + "&parentid=" + ((parentId == null) ? "" : parentId.ToString()), null);
|
||||
var parent = parentId == null
|
||||
? string.Empty
|
||||
: parentId.ToString();
|
||||
await _http.PutJsonAsync($"{Apiurl}/?siteid={siteId.ToString()}&pageid={pageId.ToString()}&parentid={parent}", null);
|
||||
}
|
||||
|
||||
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)
|
||||
|
Reference in New Issue
Block a user