|
|
|
@ -43,7 +43,7 @@ public partial class Questions
|
|
|
|
|
private async void OnDelete(int id)
|
|
|
|
|
{
|
|
|
|
|
var parameters = new ModalParameters();
|
|
|
|
|
parameters.Add(nameof(Question.Id), id);
|
|
|
|
|
parameters.Add(nameof(Question.Q_id), id);
|
|
|
|
|
|
|
|
|
|
var modal = Modal.Show<DeleteConfirmation>("Delete Confirmation", parameters);
|
|
|
|
|
var result = await modal.Result;
|
|
|
|
@ -92,21 +92,20 @@ public partial class Questions
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// When you use a real API, we use this follow code
|
|
|
|
|
//var response = await Http.GetJsonAsync<Item[]>( $"http://my-api/api/data?page={e.Page}&pageSize={e.PageSize}" );
|
|
|
|
|
var response = (await Http.GetFromJsonAsync<Question[]>($"{NavigationManager.BaseUri}fake-question.json")).Skip((e.Page - 1) * e.PageSize).Take(e.PageSize).ToList();
|
|
|
|
|
|
|
|
|
|
var response = Http.GetFromJsonAsync<Question[]>($"https://trusting-panini.87-106-126-109.plesk.page/api/questions/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO").Result;
|
|
|
|
|
|
|
|
|
|
if (!e.CancellationToken.IsCancellationRequested)
|
|
|
|
|
{
|
|
|
|
|
totalQuestion = (await Http.GetFromJsonAsync<List<Question>>($"{NavigationManager.BaseUri}fake-question.json")).Count;
|
|
|
|
|
questions = new List<Question>(response); // an actual data for the current page
|
|
|
|
|
totalQuestion = questions.Count;
|
|
|
|
|
var currentData = await LocalStorage.GetItemAsync<Question[]>("data");
|
|
|
|
|
|
|
|
|
|
// Check if data exist in the local storage
|
|
|
|
|
if (currentData == null)
|
|
|
|
|
if (currentData == null || currentData.Length != questions.Count)
|
|
|
|
|
{
|
|
|
|
|
// 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<Question[]>($"https://trusting-panini.87-106-126-109.plesk.page/api/chapters/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO").Result;
|
|
|
|
|
var originalData = Http.GetFromJsonAsync<Question[]>($"https://trusting-panini.87-106-126-109.plesk.page/api/questions/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO").Result;
|
|
|
|
|
await LocalStorage.SetItemAsync("data", originalData);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|