|
|
|
@ -58,24 +58,13 @@ public partial class Chapters
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
|
|
|
|
{
|
|
|
|
|
// Do not treat this action if is not the first render
|
|
|
|
|
if (!firstRender)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var currentData = await LocalStorage.GetItemAsync<Chapter[]>("data");
|
|
|
|
|
|
|
|
|
|
// Check if data exist in the local storage
|
|
|
|
|
if (currentData == null)
|
|
|
|
|
{
|
|
|
|
|
// this code add in the local storage the fake data (we load the data sync for initialize the data before load the OnReadData method)
|
|
|
|
|
var originalData = Http.GetFromJsonAsync<Chapter[]>($"https://trusting-panini.87-106-126-109.plesk.page/api/chapters").Result;
|
|
|
|
|
await LocalStorage.SetItemAsync("data", originalData);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//protected override async Task OnAfterRenderAsync(bool firstRender)
|
|
|
|
|
//{
|
|
|
|
|
// if (!firstRender)
|
|
|
|
|
// {
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
private async Task OnReadData(DataGridReadDataEventArgs<Chapter> e)
|
|
|
|
|
{
|
|
|
|
@ -92,7 +81,12 @@ public partial class Chapters
|
|
|
|
|
{
|
|
|
|
|
chapters = new List<Chapter>(response); // an actual data for the current page
|
|
|
|
|
totalChapter = chapters.Count;
|
|
|
|
|
|
|
|
|
|
var currentData = await LocalStorage.GetItemAsync<Chapter[]>("data");
|
|
|
|
|
if (currentData == null || currentData.Length != chapters.Count)
|
|
|
|
|
{
|
|
|
|
|
var originalData = Http.GetFromJsonAsync<Chapter[]>($"https://trusting-panini.87-106-126-109.plesk.page/api/chapters").Result;
|
|
|
|
|
await LocalStorage.SetItemAsync("data", originalData);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -116,14 +110,7 @@ public partial class Chapters
|
|
|
|
|
await IJSRuntime.InvokeVoidAsync("downloadFileFromStream", "data.csv", streamRef);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private async void Import()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// for
|
|
|
|
|
// {
|
|
|
|
|
// var formData = new MultipartFormDataContent();
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
private async Task SingleUpload(InputFileChangeEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
using (MemoryStream ms = new MemoryStream())
|
|
|
|
@ -165,7 +152,7 @@ public partial class Chapters
|
|
|
|
|
|
|
|
|
|
var formContent = new FormUrlEncodedContent(formData);
|
|
|
|
|
|
|
|
|
|
string apiUri = "https://trusting-panini.87-106-126-109.plesk.page/api/add/chapters";
|
|
|
|
|
string apiUri = "https://trusting-panini.87-106-126-109.plesk.page/api/add/chapter";
|
|
|
|
|
|
|
|
|
|
using (var httpClient = new HttpClient())
|
|
|
|
|
{
|
|
|
|
|