From a16dca6156018daf90656d786296bf4e7edf137c Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Sat, 8 Feb 2025 21:43:56 +0100 Subject: [PATCH] retablissement CI --- .../WF-WebAdmin/Pages/ComposentComplex.razor | 14 --- .../Pages/ComposentComplex.razor.cs | 92 ------------------- WF-WebAdmin/WF-WebAdmin/Pages/_Host.cshtml | 4 + .../WF-WebAdmin/Service/QuizServiceStub.cs | 58 ++++++------ 4 files changed, 33 insertions(+), 135 deletions(-) delete mode 100644 WF-WebAdmin/WF-WebAdmin/Pages/ComposentComplex.razor delete mode 100644 WF-WebAdmin/WF-WebAdmin/Pages/ComposentComplex.razor.cs diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/ComposentComplex.razor b/WF-WebAdmin/WF-WebAdmin/Pages/ComposentComplex.razor deleted file mode 100644 index ba982d0..0000000 --- a/WF-WebAdmin/WF-WebAdmin/Pages/ComposentComplex.razor +++ /dev/null @@ -1,14 +0,0 @@ -@page "/graph" -@using Syncfusion.Blazor.Charts - - - - - - - - - - - - diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/ComposentComplex.razor.cs b/WF-WebAdmin/WF-WebAdmin/Pages/ComposentComplex.razor.cs deleted file mode 100644 index 5d22acb..0000000 --- a/WF-WebAdmin/WF-WebAdmin/Pages/ComposentComplex.razor.cs +++ /dev/null @@ -1,92 +0,0 @@ -using Microsoft.AspNetCore.Components; -using MudBlazor; -using Syncfusion.Blazor.Charts.Chart.Internal; -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using System.Threading.Tasks; -using WF_WebAdmin.Model; -using WF_WebAdmin.Service; - - -namespace WF_WebAdmin.Pages -{ - public class SalesInfo - { - public string Month { get; set; } - public double SalesValue { get; set; } - } - public partial class ComposentComplex : ComponentBase - { - [Inject] public ICommentaryService CommentaryService { get; set; } = default!; - - public List Labels { get; set; } = new(); - public List ChartData { get; set; } = new(); - public List AvailableYears { get; set; } = new(); - public int SelectedYear { get; set; } - - private List AllComments = new(); - - - public List Sales = new List - { - new SalesInfo { Month = "Jan", SalesValue = 35 }, - new SalesInfo { Month = "Feb", SalesValue = 28 }, - new SalesInfo { Month = "Mar", SalesValue = 34 }, - new SalesInfo { Month = "Apr", SalesValue = 28 }, - new SalesInfo { Month = "May", SalesValue = 40 }, - new SalesInfo { Month = "Jun", SalesValue = 32 }, - new SalesInfo { Month = "Jul", SalesValue = 35 }, - new SalesInfo { Month = "Aug", SalesValue = 55 }, - new SalesInfo { Month = "Sep", SalesValue = 38 }, - new SalesInfo { Month = "Oct", SalesValue = 30 }, - new SalesInfo { Month = "Nov", SalesValue = 25 }, - new SalesInfo { Month = "Dec", SalesValue = 32 } - }; - protected override async Task OnInitializedAsync() - { - // Charger tous les commentaires - AllComments = await CommentaryService.GetCommentsAsync(); - - if (!AllComments.Any()) - { - Labels = new List { "Aucun commentaire" }; - ChartData = new List { new double[] { 0 } }; - return; - } - - AvailableYears = AllComments - .Select(c => c.DateCreation.Year) - .Distinct() - .OrderBy(y => y) - .ToList(); - - SelectedYear = AvailableYears.Max(); - - UpdateChartData(SelectedYear); - } - private void UpdateChartData(int newYear) - { - SelectedYear = newYear; - - var filteredComments = AllComments - .Where(c => c.DateCreation.Year == SelectedYear) - .ToList(); - - if (!filteredComments.Any()) - { - Labels = new List { "Aucun commentaire" }; - ChartData = new List { new double[] { 0 } }; - return; - } - - foreach (var sale in Sales) - { - sale.SalesValue = filteredComments.Count(c => c.DateCreation.Month.ToString("MMM", CultureInfo.InvariantCulture) == sale.Month); - } - - } - - } -} diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/_Host.cshtml b/WF-WebAdmin/WF-WebAdmin/Pages/_Host.cshtml index 758755d..a28d1ba 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/_Host.cshtml +++ b/WF-WebAdmin/WF-WebAdmin/Pages/_Host.cshtml @@ -6,3 +6,7 @@ } + + + + diff --git a/WF-WebAdmin/WF-WebAdmin/Service/QuizServiceStub.cs b/WF-WebAdmin/WF-WebAdmin/Service/QuizServiceStub.cs index f35612f..07914c1 100644 --- a/WF-WebAdmin/WF-WebAdmin/Service/QuizServiceStub.cs +++ b/WF-WebAdmin/WF-WebAdmin/Service/QuizServiceStub.cs @@ -1,10 +1,10 @@ -using System.Text.Json; -using WF_WebAdmin.Model; - -namespace WF_WebAdmin.Service; - -public class QuizServiceStub: IQuizService -{ +using System.Text.Json; +using WF_WebAdmin.Model; + +namespace WF_WebAdmin.Service; + +public class QuizServiceStub: IQuizService +{ private readonly string _jsonFilePath = Path.Combine(Environment.CurrentDirectory, "wwwroot", "fake_data_quiz.json"); @@ -158,18 +158,18 @@ public class QuizServiceStub: IQuizService return null; } - /// - /// Asynchronously retrieves a paginated list of quizzes, returning a specific number of quizzes for the given page. - /// - /// The number of quizzes to retrieve per page. - /// The page number to retrieve, where the first page is 1. - /// A task representing the asynchronous operation, with a result containing the quizzes for the specified page. - /// - /// This method retrieves the full list of quizzes using and returns a subset of quizzes based - /// on the specified page number and the number of quizzes per page. If the requested page exceeds the available quizzes, - /// the method returns the last page with the remaining quizzes. If the number of quizzes requested per page exceeds the - /// total number of quizzes, the method will return all quizzes available. - /// + /// + /// Asynchronously retrieves a paginated list of quizzes, returning a specific number of quizzes for the given page. + /// + /// The number of quizzes to retrieve per page. + /// The page number to retrieve, where the first page is 1. + /// A task representing the asynchronous operation, with a result containing the quizzes for the specified page. + /// + /// This method retrieves the full list of quizzes using and returns a subset of quizzes based + /// on the specified page number and the number of quizzes per page. If the requested page exceeds the available quizzes, + /// the method returns the last page with the remaining quizzes. If the number of quizzes requested per page exceeds the + /// total number of quizzes, the method will return all quizzes available. + /// public async Task> getSommeQuiz(int nb, int page) { var data = await getQuizzes(); @@ -185,18 +185,18 @@ public class QuizServiceStub: IQuizService } - /// - /// Asynchronously retrieves the total number of quizzes in the list. - /// - /// A task representing the asynchronous operation, with an result containing the total number of quizzes. - /// - /// This method retrieves the full list of quizzes using and returns the count of quizzes in the list. - /// It simply returns the number of quizzes available in the data source. - /// + /// + /// Asynchronously retrieves the total number of quizzes in the list. + /// + /// A task representing the asynchronous operation, with an result containing the total number of quizzes. + /// + /// This method retrieves the full list of quizzes using and returns the count of quizzes in the list. + /// It simply returns the number of quizzes available in the data source. + /// public async Task getNbQuiz() { var data = await getQuizzes(); return data.Count; - } + } -} +}