|
|
@ -84,8 +84,11 @@ public partial class Questions
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Calculez l'index de départ pour la pagination
|
|
|
|
var response = Http.GetFromJsonAsync<Question[]>(API.API_URL+"questions/"+API.TOKEN).Result;
|
|
|
|
int page = ((e.Page - 1) * e.PageSize)/10 + 1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Envoyez une requête à l'API pour récupérer les questions de la page actuelle
|
|
|
|
|
|
|
|
var response = await Http.GetFromJsonAsync<Question[]>(API.API_URL + "questions/" + API.TOKEN + $"?page={page}");
|
|
|
|
|
|
|
|
|
|
|
|
if (!e.CancellationToken.IsCancellationRequested && response != null)
|
|
|
|
if (!e.CancellationToken.IsCancellationRequested && response != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -99,15 +102,6 @@ public partial class Questions
|
|
|
|
questions = selectedQuestions;
|
|
|
|
questions = selectedQuestions;
|
|
|
|
|
|
|
|
|
|
|
|
totalQuestion = questions.Count;
|
|
|
|
totalQuestion = questions.Count;
|
|
|
|
var currentData = await LocalStorage.GetItemAsync<Question[]>("data");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Check if data exist in the local storage
|
|
|
|
|
|
|
|
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[]>(API.API_URL+"chapters/"+API.TOKEN).Result;
|
|
|
|
|
|
|
|
await LocalStorage.SetItemAsync("data", originalData);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|