|
|
|
@ -51,27 +51,33 @@ public partial class Administrators
|
|
|
|
|
{
|
|
|
|
|
administrators = new List<Administrator>(response); // an actual data for the current page
|
|
|
|
|
totalItem = administrators.Count;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
|
|
|
|
var currentData = await LocalStorage.GetItemAsync<Administrator[]>("data");
|
|
|
|
|
if (currentData == null || currentData.Length != administrators.Count)
|
|
|
|
|
{
|
|
|
|
|
// Do not treat this action if is not the first render
|
|
|
|
|
if (!firstRender)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var currentData = await LocalStorage.GetItemAsync<AdministratorModel[]>("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<AdministratorModel[]>($"https://trusting-panini.87-106-126-109.plesk.page/api/administrators").Result;
|
|
|
|
|
var originalData = Http.GetFromJsonAsync<Administrator[]>($"https://trusting-panini.87-106-126-109.plesk.page/api/administrators").Result;
|
|
|
|
|
await LocalStorage.SetItemAsync("data", originalData);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//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<AdministratorModel[]>("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<AdministratorModel[]>($"https://trusting-panini.87-106-126-109.plesk.page/api/administrators").Result;
|
|
|
|
|
// await LocalStorage.SetItemAsync("data", originalData);
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
private async void OnDelete(int id)
|
|
|
|
|
{
|
|
|
|
|