diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/Accueil.razor b/WF-WebAdmin/WF-WebAdmin/Pages/Accueil.razor
index d9af67e..34ec508 100644
--- a/WF-WebAdmin/WF-WebAdmin/Pages/Accueil.razor
+++ b/WF-WebAdmin/WF-WebAdmin/Pages/Accueil.razor
@@ -3,7 +3,7 @@
($"{NavigationManager.BaseUri}fake-dataDailyQuote.json"); - + var url = $"{NavigationManager.BaseUri}fake-dataDailyQuote.json"; + + try + { + var response = await Http.GetFromJsonAsync(url); + Dailyquote = response ?? Array.Empty(); // Assurer qu'on ne stocke pas null + } + catch (Exception ex) + { + Console.WriteLine($"Erreur lors du chargement des citations : {ex.Message}"); + Dailyquote = Array.Empty(); // Éviter une exception en cas d'erreur réseau + } } - private async void RandomDailyquote() + private async Task RandomDailyquote() { - string _jsonFilePath = Path.Combine(Environment.CurrentDirectory, "wwwroot", "fake-dataDailyQuote.json"); - Random random = new Random(); + try + { + string _jsonFilePath = Path.Combine(Environment.CurrentDirectory, "wwwroot", "fake-dataDailyQuote.json"); + Random random = new Random(); - Quote[] quotes = await Http.GetFromJsonAsync($"{NavigationManager.BaseUri}fake-dataQuote.json"); + var response = await Http.GetFromJsonAsync($"{NavigationManager.BaseUri}fake-dataQuote.json"); + Quote[] quotes = response ?? Array.Empty(); // Empêche null - Dailyquote = new Quote[] { quotes.OrderBy(x => random.Next()).First() }; + if (quotes.Length > 0) + { + Dailyquote = new Quote[] { quotes.OrderBy(x => random.Next()).First() }; + } + else + { + Console.WriteLine("Aucune citation disponible dans le fichier JSON."); + return; + } - var json = JsonSerializer.Serialize(Dailyquote, new JsonSerializerOptions { WriteIndented = true }); - await File.WriteAllTextAsync(_jsonFilePath, json); + var json = JsonSerializer.Serialize(Dailyquote, new JsonSerializerOptions { WriteIndented = true }); + await File.WriteAllTextAsync(_jsonFilePath, json); - LoggerSaveStub.Log(Logger, LogLevel.Information, "Random change of quote of the day"); + if (Logger != null) + { + LoggerSaveStub.Log(Logger, LogLevel.Information, "Random change of quote of the day"); + } + else + { + Console.WriteLine("Logger non initialisé."); + } + } + catch (Exception ex) + { + Console.WriteLine($"Erreur dans RandomDailyquote: {ex.Message}"); + } } } } diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs b/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs index 6b3da7e..1eae8a6 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs +++ b/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs @@ -16,7 +16,6 @@ namespace WF_WebAdmin.Pages private Listusers; - private bool showDeletePopup = false; private bool showModifyPopup = false; private User userToDelete = null; private User selectedUser; @@ -164,7 +163,6 @@ namespace WF_WebAdmin.Pages private void ClosePopup() { // Set all popup visibility flags to false to hide the popups - showDeletePopup = false; // Close the delete confirmation popup showModifyPopup = false; // Close the modify confirmation popup showPopupDelete = false; // Close any additional delete popups showPopupAdmin = false; // Close the admin-related popup (if any) diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/_Host.cshtml b/WF-WebAdmin/WF-WebAdmin/Pages/_Host.cshtml index a28d1ba..4565061 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/_Host.cshtml +++ b/WF-WebAdmin/WF-WebAdmin/Pages/_Host.cshtml @@ -1,4 +1,13 @@ -@page "/" +@* + File: _Host.cshtml + Project: WF_WebAdmin + Description: ... + Author: What The Fantasy + Created: 10/02/2025 + Last Modified: 10/02/2025 +*@ + +@page "/" @namespace WF_WebAdmin.Pages @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers @{ @@ -8,5 +17,5 @@ - - + +