@@ -21,13 +21,13 @@
PageSize="10"
ShowPager
Responsive>
-
-
+
+
-
+
- Editer
-
+ Editer
+
\ No newline at end of file
diff --git a/Blazor/Blazor/Pages/Questions/Questions.razor.cs b/Blazor/Blazor/Pages/Questions/Questions.razor.cs
index e7e75b7..fb18ffa 100644
--- a/Blazor/Blazor/Pages/Questions/Questions.razor.cs
+++ b/Blazor/Blazor/Pages/Questions/Questions.razor.cs
@@ -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("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( $"http://my-api/api/data?page={e.Page}&pageSize={e.PageSize}" );
- var response = (await Http.GetFromJsonAsync($"{NavigationManager.BaseUri}fake-question.json")).Skip((e.Page - 1) * e.PageSize).Take(e.PageSize).ToList();
+
+ var response = Http.GetFromJsonAsync($"https://trusting-panini.87-106-126-109.plesk.page/api/questions/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO").Result;
if (!e.CancellationToken.IsCancellationRequested)
{
- totalQuestion = (await Http.GetFromJsonAsync>($"{NavigationManager.BaseUri}fake-question.json")).Count;
questions = new List(response); // an actual data for the current page
+ totalQuestion = questions.Count;
var currentData = await LocalStorage.GetItemAsync("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($"https://trusting-panini.87-106-126-109.plesk.page/api/chapters/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO").Result;
+ var originalData = Http.GetFromJsonAsync($"https://trusting-panini.87-106-126-109.plesk.page/api/questions/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO").Result;
await LocalStorage.SetItemAsync("data", originalData);
}
}
diff --git a/Blazor/Blazor/Services/DataLocalService.cs b/Blazor/Blazor/Services/DataLocalService.cs
index 732059a..8956c0e 100644
--- a/Blazor/Blazor/Services/DataLocalService.cs
+++ b/Blazor/Blazor/Services/DataLocalService.cs
@@ -232,7 +232,7 @@ namespace Blazor.Services
var currentData = _http.GetFromJsonAsync>($"https://trusting-panini.87-106-126-109.plesk.page/api/questions/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO").Result;
// Get the question int the list
- var question = currentData.FirstOrDefault(w => w.Id == id);
+ var question = currentData.FirstOrDefault(w => w.Q_id == id);
// Check if question exist
if (question == null)
@@ -249,7 +249,7 @@ namespace Blazor.Services
var currentData = await _localStorage.GetItemAsync>("data");
// Get the admin int the list
- var question = currentData.FirstOrDefault(w => w.Id == id);
+ var question = currentData.FirstOrDefault(w => w.Q_id == id);
// Check if admin exist
if (question == null)
@@ -258,7 +258,7 @@ namespace Blazor.Services
}
// Modify the content of the adminnistrator
- question.Content = model.Content;
+ question.Q_content = model.Content;
// Save the data
await _localStorage.SetItemAsync("data", currentData);
@@ -270,13 +270,13 @@ namespace Blazor.Services
var currentData = await _localStorage.GetItemAsync>("data");
// Simulate the Id
- model.Id = currentData.Max(s => s.Id) + 1;
+ model.Id = currentData.Max(s => s.Q_id) + 1;
// Add the admin to the current data
currentData.Add(new Question
{
- Id = model.Id,
- Content = model.Content
+ Q_id = model.Id,
+ Q_content = model.Content
});
diff --git a/Blazor/Blazor/ViewClasses/Question.cs b/Blazor/Blazor/ViewClasses/Question.cs
index 4586917..125455d 100644
--- a/Blazor/Blazor/ViewClasses/Question.cs
+++ b/Blazor/Blazor/ViewClasses/Question.cs
@@ -2,8 +2,8 @@
public class Question
{
- public int Id { get; set; }
- public string Content { get; set; }
+ public int Q_id { get; set; }
+ public string Q_content { get; set; }
public int IdChapter { get; set; }
public int IdAnswerGood { get; set; }
public int Difficulty { get; set; }