From 63e755c5c79524077cb146568962b6260dd48b3f Mon Sep 17 00:00:00 2001 From: mirage <119869686+ClementBobin@users.noreply.github.com> Date: Tue, 31 Mar 2026 10:07:47 +0200 Subject: [PATCH 01/22] =?UTF-8?q?refactor:=20#150=20mettre=20=C3=A0=20jour?= =?UTF-8?q?=20appsettings=20et=20introduire=20des=20enums=20pour=20les=20t?= =?UTF-8?q?ypes=20Seeder=20et=20Repository?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/pr-endpoint-check.yml | 16 ++----- .../Dockerfile => Dockerfile | 2 +- .../Configuration/AppEnums.cs | 13 ++++++ Webzine.WebApplication/Program.cs | 42 +++++++------------ .../appsettings.Development.json | 8 +--- .../appsettings.Production.json | 4 ++ Webzine.WebApplication/appsettings.json | 6 +-- 7 files changed, 39 insertions(+), 52 deletions(-) rename Webzine.WebApplication/Dockerfile => Dockerfile (88%) create mode 100644 Webzine.WebApplication/Configuration/AppEnums.cs create mode 100644 Webzine.WebApplication/appsettings.Production.json diff --git a/.gitea/workflows/pr-endpoint-check.yml b/.gitea/workflows/pr-endpoint-check.yml index 427f687..aadf030 100644 --- a/.gitea/workflows/pr-endpoint-check.yml +++ b/.gitea/workflows/pr-endpoint-check.yml @@ -11,20 +11,10 @@ jobs: - name: Checkout PR branch uses: actions/checkout@v4 - - name: Configure appsettings for CI + - name: Configure environment for CI run: | - # Find the appsettings.json file - APPSETTINGS_PATH="Webzine.WebApplication/appsettings.json" - - # Backup original file - cp $APPSETTINGS_PATH $APPSETTINGS_PATH.bak - - # Use jq to modify the JSON - jq '.UseDatabase = true | .IsSQLite = true' $APPSETTINGS_PATH > $APPSETTINGS_PATH.tmp - mv $APPSETTINGS_PATH.tmp $APPSETTINGS_PATH - - echo "Updated appsettings.json:" - cat $APPSETTINGS_PATH + echo "ASPNETCORE_ENVIRONMENT=Development" >> $ACT_ENV + echo "Repository=Db" >> $ACT_ENV - name: Setup .NET 10 uses: actions/setup-dotnet@v4 diff --git a/Webzine.WebApplication/Dockerfile b/Dockerfile similarity index 88% rename from Webzine.WebApplication/Dockerfile rename to Dockerfile index 3211249..bd375cc 100644 --- a/Webzine.WebApplication/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ EXPOSE 8081 FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build ARG BUILD_CONFIGURATION=Release WORKDIR /src -COPY ["Webzine.WebApplication/Webzine.WebApplication.csproj", "Webzine.WebApplication/"] +COPY ["./Webzine.WebApplication/Webzine.WebApplication.csproj", "Webzine.WebApplication/"] RUN dotnet restore "Webzine.WebApplication/Webzine.WebApplication.csproj" COPY . . WORKDIR "/src/Webzine.WebApplication" diff --git a/Webzine.WebApplication/Configuration/AppEnums.cs b/Webzine.WebApplication/Configuration/AppEnums.cs new file mode 100644 index 0000000..93d4e8b --- /dev/null +++ b/Webzine.WebApplication/Configuration/AppEnums.cs @@ -0,0 +1,13 @@ +namespace Webzine.WebApplication.Configuration; + +public enum SeederType +{ + Local, + Spotify +} + +public enum RepositoryType +{ + Local, + Db +} \ No newline at end of file diff --git a/Webzine.WebApplication/Program.cs b/Webzine.WebApplication/Program.cs index ae26f07..1b763dc 100644 --- a/Webzine.WebApplication/Program.cs +++ b/Webzine.WebApplication/Program.cs @@ -8,6 +8,7 @@ using Webzine.Entity; using Webzine.Entity.Fixtures; using Webzine.Repository; using Webzine.Repository.Contracts; +using Webzine.WebApplication.Configuration; using Webzine.WebApplication.Extensions; // Initiation du logger NLog pour la classe courante afin de pouvoir l'utiliser pour logger des messages d'information, d'erreur, etc avant la construction de l'application. @@ -32,19 +33,19 @@ try builder.Host.UseNLog(); // En fonction de la configuration, utilise soit les repositories basés sur une base de données, soit les repositories basés sur des listes locales. - bool useDatabase = builder.Configuration.GetValue("UseDatabase"); - bool isSQLite = builder.Configuration.GetValue("IsSQLite"); - if (useDatabase) + var repositoryType = builder.Configuration.GetValue("Repository"); + var seederType = builder.Configuration.GetValue("Seeder"); + if (repositoryType == RepositoryType.Db) { - if (isSQLite) + if (builder.Environment.IsProduction()) { builder.Services.AddDbContext(options => - options.UseSqlite(builder.Configuration.GetConnectionString("SqliteConnection"))); + options.UseNpgsql(builder.Configuration.GetConnectionString("PostGreSQLConnection"))); } else { builder.Services.AddDbContext(options => - options.UseNpgsql(builder.Configuration.GetConnectionString("PostGreSQLConnection"))); + options.UseSqlite(builder.Configuration.GetConnectionString("SqliteConnection"))); } builder.Services.AddScoped(); @@ -68,30 +69,15 @@ try var app = builder.Build(); - if (useDatabase) + if (repositoryType == RepositoryType.Db) { - if (isSQLite) + using (var scope = app.Services.CreateScope()) { - using (var scope = app.Services.CreateScope()) - { - var db = scope.ServiceProvider.GetRequiredService(); - db.Database.EnsureDeleted(); - db.Database.EnsureCreated(); - var repo = scope.ServiceProvider.GetRequiredService(); - repo.SeedBaseDeDonnees(); - } - } - else - { - using (var scope = app.Services.CreateScope()) - { - // TODO : A modifier pour ne pas supprimer la base de donnée en prod - var db = scope.ServiceProvider.GetRequiredService(); - db.Database.EnsureDeleted(); - db.Database.EnsureCreated(); - var repo = scope.ServiceProvider.GetRequiredService(); - repo.SeedBaseDeDonnees(); - } + var db = scope.ServiceProvider.GetRequiredService(); + db.Database.EnsureDeleted(); + db.Database.EnsureCreated(); + var repo = scope.ServiceProvider.GetRequiredService(); + repo.SeedBaseDeDonnees(); } } else diff --git a/Webzine.WebApplication/appsettings.Development.json b/Webzine.WebApplication/appsettings.Development.json index 0c208ae..79222b7 100644 --- a/Webzine.WebApplication/appsettings.Development.json +++ b/Webzine.WebApplication/appsettings.Development.json @@ -1,8 +1,4 @@ { - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft.AspNetCore": "Warning" - } - } + "Seeder": "Local", + "Repository": "Db" } diff --git a/Webzine.WebApplication/appsettings.Production.json b/Webzine.WebApplication/appsettings.Production.json new file mode 100644 index 0000000..0609b7f --- /dev/null +++ b/Webzine.WebApplication/appsettings.Production.json @@ -0,0 +1,4 @@ +{ + "Seeder": "Local", + "Repository": "Db" +} \ No newline at end of file diff --git a/Webzine.WebApplication/appsettings.json b/Webzine.WebApplication/appsettings.json index fc87614..ac0f745 100644 --- a/Webzine.WebApplication/appsettings.json +++ b/Webzine.WebApplication/appsettings.json @@ -9,11 +9,9 @@ "NombreDerniereChronique": 3, "NombreDeTopTitres": 3 }, - "UseDatabase": true, - "IsSQLite": true, "ConnectionStrings": { "SqliteConnection": "Data Source=Data/webzine.sqlite", - "PostGreSQLConnection" : "Host=localhost;Port=5432;Username=admin;Password=admin123;Database=webzine_db" + "PostGreSQLConnection": "Host=192.168.60.50;Port=5432;Username=postgres;Password=BcS4e6DHr2NgVrnPomVI;Database=webzine_prod" }, "AllowedHosts": "*" -} +} \ No newline at end of file From 29f1fd97be59f1e2807cba211d337694bc095c1d Mon Sep 17 00:00:00 2001 From: mirage <119869686+ClementBobin@users.noreply.github.com> Date: Tue, 31 Mar 2026 10:08:08 +0200 Subject: [PATCH 02/22] =?UTF-8?q?refactor:=20mise=20=C3=A0=20jour=20la=20v?= =?UTF-8?q?ersion=20de=20l'application=20=C3=A0=203.0=20dans=20ApiControll?= =?UTF-8?q?er?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Webzine.WebApplication/Controllers/ApiController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Webzine.WebApplication/Controllers/ApiController.cs b/Webzine.WebApplication/Controllers/ApiController.cs index 1b1beca..f01d7a1 100644 --- a/Webzine.WebApplication/Controllers/ApiController.cs +++ b/Webzine.WebApplication/Controllers/ApiController.cs @@ -29,7 +29,7 @@ public class ApiController : ControllerBase return this.Ok(new { nom = "webzine", - version = "2.0", + version = "3.0", }); } } \ No newline at end of file From aa4ad9ef8e4618eef86a040c4da66a592eac0995 Mon Sep 17 00:00:00 2001 From: mirage <119869686+ClementBobin@users.noreply.github.com> Date: Tue, 31 Mar 2026 10:22:11 +0200 Subject: [PATCH 03/22] =?UTF-8?q?refactor:=20mise=20=C3=A0=20jour=20la=20c?= =?UTF-8?q?onfiguration=20des=20variables=20d=E2=80=99environnement=20dans?= =?UTF-8?q?=20pr-endpoint-check.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/pr-endpoint-check.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/pr-endpoint-check.yml b/.gitea/workflows/pr-endpoint-check.yml index aadf030..e487e80 100644 --- a/.gitea/workflows/pr-endpoint-check.yml +++ b/.gitea/workflows/pr-endpoint-check.yml @@ -13,8 +13,8 @@ jobs: - name: Configure environment for CI run: | - echo "ASPNETCORE_ENVIRONMENT=Development" >> $ACT_ENV - echo "Repository=Db" >> $ACT_ENV + echo "ASPNETCORE_ENVIRONMENT=Development" >> "${GITHUB_ENV:-$ACT_ENV}" + echo "Repository=Db" >> "${GITHUB_ENV:-$ACT_ENV}" - name: Setup .NET 10 uses: actions/setup-dotnet@v4 From 8eaefe79034db67c590824bfabbc9fddbdde1d01 Mon Sep 17 00:00:00 2001 From: "josephine.vetu" Date: Tue, 31 Mar 2026 11:16:34 +0200 Subject: [PATCH 04/22] =?UTF-8?q?#144=20Ajout=20des=20fichiers=20commit-ms?= =?UTF-8?q?g=20et=20pre-commit.=20Modification=20de=20.editorconfig=20pour?= =?UTF-8?q?=20ajouter=20des=20r=C3=A8gles=20personnalis=C3=A9es.=20Exclusi?= =?UTF-8?q?on=20de=20Progam.cs=20pour=20l'erreur=20SA1200.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .editorconfig | 500 +++++++++--------- .../equipe 1 - dossier de configuration.md | 68 ++- Webzine.Documentation/StyleCop/stylecop.json | 4 +- Webzine.Documentation/git_hooks/commit-msg | 24 + Webzine.Documentation/git_hooks/pre-commit | 21 + Webzine.Entity.Tests/.editorconfig | 2 + Webzine.Repository/DbArtisteRepository.cs | 2 - Webzine.Repository/DbStyleRepository.cs | 5 +- Webzine.Repository/DbTitreRepository.cs | 5 +- Webzine.Repository/LocalStyleRepository.cs | 5 +- Webzine.Repository/LocalTitreRepository.cs | 5 +- .../Controllers/ArtisteController.cs | 7 +- .../Controllers/DashboardController.cs | 6 +- .../Controllers/TitreController.cs | 5 +- .../ViewModels/Titre/AdminTitreForm.cs | 4 +- .../Controllers/ApiController.cs | 4 +- .../Extensions/RouteConfiguration.cs | 2 +- Webzine.WebApplication/Program.cs | 3 + .../Recherche/RechercheIndexViewModel.cs | 4 +- .../ViewModels/Titre/TitreComment.cs | 4 +- .../ViewModels/Titre/TitreContent.cs | 4 +- 21 files changed, 374 insertions(+), 310 deletions(-) create mode 100644 Webzine.Documentation/git_hooks/commit-msg create mode 100644 Webzine.Documentation/git_hooks/pre-commit create mode 100644 Webzine.Entity.Tests/.editorconfig diff --git a/.editorconfig b/.editorconfig index 9896049..19e562e 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,64 +1,59 @@ root = true -# All files +# ============================================================ +# ALL FILES +# ============================================================ [*] indent_style = space -# Xml files +# ============================================================ +# XML FILES +# ============================================================ [*.xml] indent_size = 2 -# Xml project files [*.{csproj,fsproj,vbproj,proj,slnx}] indent_size = 2 -# Xml config files [*.{props,targets,config,nuspec}] indent_size = 2 +# ============================================================ +# JSON FILES +# ============================================================ [*.json] indent_size = 2 -# C# files -[*.cs] - -#### Core EditorConfig Options #### - -# Indentation and spacing -indent_size = 4 -tab_width = 4 - -# New line preferences -insert_final_newline = false - -#### .NET Coding Conventions #### +# ============================================================ +# C# AND VB FILES — SHARED .NET CONVENTIONS +# ============================================================ [*.{cs,vb}] -# Organize usings +#### Organize Usings #### dotnet_separate_import_directive_groups = true dotnet_sort_system_directives_first = true file_header_template = unset -# this. and Me. preferences +#### this. and Me. Preferences #### dotnet_style_qualification_for_event = false:silent dotnet_style_qualification_for_field = false:silent dotnet_style_qualification_for_method = false:silent dotnet_style_qualification_for_property = false:silent -# Language keywords vs BCL types preferences +#### Language Keywords vs BCL Types #### dotnet_style_predefined_type_for_locals_parameters_members = true:silent dotnet_style_predefined_type_for_member_access = true:silent -# Parentheses preferences +#### Parentheses Preferences #### dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent -# Modifier preferences +#### Modifier Preferences #### dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent -# Expression-level preferences +#### Expression-Level Preferences #### dotnet_style_coalesce_expression = true:suggestion dotnet_style_collection_initializer = true:suggestion dotnet_style_explicit_tuple_names = true:suggestion @@ -78,129 +73,30 @@ dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggesti dotnet_style_prefer_simplified_boolean_expressions = true:suggestion dotnet_style_prefer_simplified_interpolation = true:suggestion -# Field preferences +#### Field Preferences #### dotnet_style_readonly_field = true:warning -# Parameter preferences +#### Parameter Preferences #### dotnet_code_quality_unused_parameters = all:suggestion -# Suppression preferences +#### Suppression Preferences #### dotnet_remove_unnecessary_suppression_exclusions = none -#### C# Coding Conventions #### -[*.cs] +#### Diagnostics #### +dotnet_diagnostic.IDE0005.severity = warning # Remove unused usings +dotnet_diagnostic.IDE0073.severity = none # File header not required +dotnet_diagnostic.SA1600.severity = warning # Elements should be documented +dotnet_diagnostic.SA1623.severity = none # Property summary text +dotnet_diagnostic.SA1624.severity = none # Property summary text +dotnet_diagnostic.SA1633.severity = none # File header not required +dotnet_diagnostic.SA1642.severity = suggestion # Constructor summary text -# var preferences -csharp_style_var_elsewhere = false:silent -csharp_style_var_for_built_in_types = false:silent -csharp_style_var_when_type_is_apparent = false:silent - -# Expression-bodied members -csharp_style_expression_bodied_accessors = true:silent -csharp_style_expression_bodied_constructors = false:silent -csharp_style_expression_bodied_indexers = true:silent -csharp_style_expression_bodied_lambdas = true:suggestion -csharp_style_expression_bodied_local_functions = false:silent -csharp_style_expression_bodied_methods = false:silent -csharp_style_expression_bodied_operators = false:silent -csharp_style_expression_bodied_properties = true:silent - -# Pattern matching preferences -csharp_style_pattern_matching_over_as_with_null_check = true:suggestion -csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion -csharp_style_prefer_extended_property_pattern = true:suggestion -csharp_style_prefer_not_pattern = true:suggestion -csharp_style_prefer_pattern_matching = true:silent -csharp_style_prefer_switch_expression = true:suggestion - -# Null-checking preferences -csharp_style_conditional_delegate_call = true:suggestion - -# Modifier preferences -csharp_prefer_static_anonymous_function = true:suggestion -csharp_prefer_static_local_function = true:warning -csharp_preferred_modifier_order = public,private,protected,internal,file,const,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,required,volatile,async:suggestion -csharp_style_prefer_readonly_struct = true:suggestion -csharp_style_prefer_readonly_struct_member = true:suggestion - -# Code-block preferences -csharp_prefer_braces = true:silent -csharp_prefer_simple_using_statement = true:suggestion -csharp_style_namespace_declarations = file_scoped:suggestion -csharp_style_prefer_method_group_conversion = true:silent -csharp_style_prefer_primary_constructors = true:suggestion -csharp_style_prefer_top_level_statements = true:silent - -# Expression-level preferences -csharp_prefer_simple_default_expression = true:suggestion -csharp_style_deconstructed_variable_declaration = true:suggestion -csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion -csharp_style_inlined_variable_declaration = true:suggestion -csharp_style_prefer_index_operator = true:suggestion -csharp_style_prefer_local_over_anonymous_function = true:suggestion -csharp_style_prefer_null_check_over_type_check = true:suggestion -csharp_style_prefer_range_operator = true:suggestion -csharp_style_prefer_tuple_swap = true:suggestion -csharp_style_prefer_utf8_string_literals = true:suggestion -csharp_style_throw_expression = true:suggestion -csharp_style_unused_value_assignment_preference = discard_variable:suggestion -csharp_style_unused_value_expression_statement_preference = discard_variable:silent - -# 'using' directive preferences -csharp_using_directive_placement = outside_namespace:silent - -#### C# Formatting Rules #### - -# New line preferences -csharp_new_line_before_catch = true -csharp_new_line_before_else = true -csharp_new_line_before_finally = true -csharp_new_line_before_members_in_anonymous_types = true -csharp_new_line_before_members_in_object_initializers = true -csharp_new_line_before_open_brace = all -csharp_new_line_between_query_expression_clauses = true - -# Indentation preferences -csharp_indent_block_contents = true -csharp_indent_braces = false -csharp_indent_case_contents = true -csharp_indent_case_contents_when_block = true -csharp_indent_labels = one_less_than_current -csharp_indent_switch_labels = true - -# Space preferences -csharp_space_after_cast = false -csharp_space_after_colon_in_inheritance_clause = true -csharp_space_after_comma = true -csharp_space_after_dot = false -csharp_space_after_keywords_in_control_flow_statements = true -csharp_space_after_semicolon_in_for_statement = true -csharp_space_around_binary_operators = before_and_after -csharp_space_around_declaration_statements = false -csharp_space_before_colon_in_inheritance_clause = true -csharp_space_before_comma = false -csharp_space_before_dot = false -csharp_space_before_open_square_brackets = false -csharp_space_before_semicolon_in_for_statement = false -csharp_space_between_empty_square_brackets = false -csharp_space_between_method_call_empty_parameter_list_parentheses = false -csharp_space_between_method_call_name_and_opening_parenthesis = false -csharp_space_between_method_call_parameter_list_parentheses = false -csharp_space_between_method_declaration_empty_parameter_list_parentheses = false -csharp_space_between_method_declaration_name_and_open_parenthesis = false -csharp_space_between_method_declaration_parameter_list_parentheses = false -csharp_space_between_parentheses = false -csharp_space_between_square_brackets = false - -# Wrapping preferences -csharp_preserve_single_line_blocks = true -csharp_preserve_single_line_statements = true - -#### Naming styles #### +# ============================================================ +# NAMING RULES +# ============================================================ [*.{cs,vb}] -# Naming rules - +## Rules ## dotnet_naming_rule.types_and_namespaces_should_be_pascalcase.severity = suggestion dotnet_naming_rule.types_and_namespaces_should_be_pascalcase.symbols = types_and_namespaces dotnet_naming_rule.types_and_namespaces_should_be_pascalcase.style = pascalcase @@ -225,6 +121,38 @@ dotnet_naming_rule.events_should_be_pascalcase.severity = suggestion dotnet_naming_rule.events_should_be_pascalcase.symbols = events dotnet_naming_rule.events_should_be_pascalcase.style = pascalcase +dotnet_naming_rule.public_fields_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.public_fields_should_be_pascalcase.symbols = public_fields +dotnet_naming_rule.public_fields_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.public_constant_fields_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.public_constant_fields_should_be_pascalcase.symbols = public_constant_fields +dotnet_naming_rule.public_constant_fields_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.public_static_readonly_fields_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.public_static_readonly_fields_should_be_pascalcase.symbols = public_static_readonly_fields +dotnet_naming_rule.public_static_readonly_fields_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.private_fields_should_be__camelcase.severity = suggestion +dotnet_naming_rule.private_fields_should_be__camelcase.symbols = private_fields +dotnet_naming_rule.private_fields_should_be__camelcase.style = _camelcase + +dotnet_naming_rule.private_static_fields_should_be_s_camelcase.severity = suggestion +dotnet_naming_rule.private_static_fields_should_be_s_camelcase.symbols = private_static_fields +dotnet_naming_rule.private_static_fields_should_be_s_camelcase.style = s_camelcase + +dotnet_naming_rule.private_constant_fields_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.private_constant_fields_should_be_pascalcase.symbols = private_constant_fields +dotnet_naming_rule.private_constant_fields_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.private_static_readonly_fields_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.private_static_readonly_fields_should_be_pascalcase.symbols = private_static_readonly_fields +dotnet_naming_rule.private_static_readonly_fields_should_be_pascalcase.style = pascalcase + +dotnet_naming_rule.enums_should_be_pascalcase.severity = suggestion +dotnet_naming_rule.enums_should_be_pascalcase.symbols = enums +dotnet_naming_rule.enums_should_be_pascalcase.style = pascalcase + dotnet_naming_rule.local_variables_should_be_camelcase.severity = suggestion dotnet_naming_rule.local_variables_should_be_camelcase.symbols = local_variables dotnet_naming_rule.local_variables_should_be_camelcase.style = camelcase @@ -237,38 +165,6 @@ dotnet_naming_rule.parameters_should_be_camelcase.severity = suggestion dotnet_naming_rule.parameters_should_be_camelcase.symbols = parameters dotnet_naming_rule.parameters_should_be_camelcase.style = camelcase -dotnet_naming_rule.public_fields_should_be_pascalcase.severity = suggestion -dotnet_naming_rule.public_fields_should_be_pascalcase.symbols = public_fields -dotnet_naming_rule.public_fields_should_be_pascalcase.style = pascalcase - -dotnet_naming_rule.private_fields_should_be__camelcase.severity = suggestion -dotnet_naming_rule.private_fields_should_be__camelcase.symbols = private_fields -dotnet_naming_rule.private_fields_should_be__camelcase.style = _camelcase - -dotnet_naming_rule.private_static_fields_should_be_s_camelcase.severity = suggestion -dotnet_naming_rule.private_static_fields_should_be_s_camelcase.symbols = private_static_fields -dotnet_naming_rule.private_static_fields_should_be_s_camelcase.style = s_camelcase - -dotnet_naming_rule.public_constant_fields_should_be_pascalcase.severity = suggestion -dotnet_naming_rule.public_constant_fields_should_be_pascalcase.symbols = public_constant_fields -dotnet_naming_rule.public_constant_fields_should_be_pascalcase.style = pascalcase - -dotnet_naming_rule.private_constant_fields_should_be_pascalcase.severity = suggestion -dotnet_naming_rule.private_constant_fields_should_be_pascalcase.symbols = private_constant_fields -dotnet_naming_rule.private_constant_fields_should_be_pascalcase.style = pascalcase - -dotnet_naming_rule.public_static_readonly_fields_should_be_pascalcase.severity = suggestion -dotnet_naming_rule.public_static_readonly_fields_should_be_pascalcase.symbols = public_static_readonly_fields -dotnet_naming_rule.public_static_readonly_fields_should_be_pascalcase.style = pascalcase - -dotnet_naming_rule.private_static_readonly_fields_should_be_pascalcase.severity = suggestion -dotnet_naming_rule.private_static_readonly_fields_should_be_pascalcase.symbols = private_static_readonly_fields -dotnet_naming_rule.private_static_readonly_fields_should_be_pascalcase.style = pascalcase - -dotnet_naming_rule.enums_should_be_pascalcase.severity = suggestion -dotnet_naming_rule.enums_should_be_pascalcase.symbols = enums -dotnet_naming_rule.enums_should_be_pascalcase.style = pascalcase - dotnet_naming_rule.local_functions_should_be_pascalcase.severity = suggestion dotnet_naming_rule.local_functions_should_be_pascalcase.symbols = local_functions dotnet_naming_rule.local_functions_should_be_pascalcase.style = pascalcase @@ -277,67 +173,35 @@ dotnet_naming_rule.non_field_members_should_be_pascalcase.severity = suggestion dotnet_naming_rule.non_field_members_should_be_pascalcase.symbols = non_field_members dotnet_naming_rule.non_field_members_should_be_pascalcase.style = pascalcase -# Symbol specifications +## Symbol Specifications ## +dotnet_naming_symbols.types_and_namespaces.applicable_kinds = namespace, class, struct, interface, enum +dotnet_naming_symbols.types_and_namespaces.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.types_and_namespaces.required_modifiers = dotnet_naming_symbols.interfaces.applicable_kinds = interface dotnet_naming_symbols.interfaces.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected -dotnet_naming_symbols.interfaces.required_modifiers = +dotnet_naming_symbols.interfaces.required_modifiers = -dotnet_naming_symbols.enums.applicable_kinds = enum -dotnet_naming_symbols.enums.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected -dotnet_naming_symbols.enums.required_modifiers = - -dotnet_naming_symbols.events.applicable_kinds = event -dotnet_naming_symbols.events.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected -dotnet_naming_symbols.events.required_modifiers = +# NOTE: was previously misconfigured as 'namespace' kind — corrected to 'type_parameter' +dotnet_naming_symbols.type_parameters.applicable_kinds = type_parameter +dotnet_naming_symbols.type_parameters.applicable_accessibilities = * +dotnet_naming_symbols.type_parameters.required_modifiers = dotnet_naming_symbols.methods.applicable_kinds = method dotnet_naming_symbols.methods.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected -dotnet_naming_symbols.methods.required_modifiers = +dotnet_naming_symbols.methods.required_modifiers = dotnet_naming_symbols.properties.applicable_kinds = property dotnet_naming_symbols.properties.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected -dotnet_naming_symbols.properties.required_modifiers = +dotnet_naming_symbols.properties.required_modifiers = + +dotnet_naming_symbols.events.applicable_kinds = event +dotnet_naming_symbols.events.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.events.required_modifiers = dotnet_naming_symbols.public_fields.applicable_kinds = field dotnet_naming_symbols.public_fields.applicable_accessibilities = public, internal -dotnet_naming_symbols.public_fields.required_modifiers = - -dotnet_naming_symbols.private_fields.applicable_kinds = field -dotnet_naming_symbols.private_fields.applicable_accessibilities = private, protected, protected_internal, private_protected -dotnet_naming_symbols.private_fields.required_modifiers = - -dotnet_naming_symbols.private_static_fields.applicable_kinds = field -dotnet_naming_symbols.private_static_fields.applicable_accessibilities = private, protected, protected_internal, private_protected -dotnet_naming_symbols.private_static_fields.required_modifiers = static - -dotnet_naming_symbols.types_and_namespaces.applicable_kinds = namespace, class, struct, interface, enum -dotnet_naming_symbols.types_and_namespaces.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected -dotnet_naming_symbols.types_and_namespaces.required_modifiers = - -dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method -dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected -dotnet_naming_symbols.non_field_members.required_modifiers = - -dotnet_naming_symbols.type_parameters.applicable_kinds = namespace -dotnet_naming_symbols.type_parameters.applicable_accessibilities = * -dotnet_naming_symbols.type_parameters.required_modifiers = - -dotnet_naming_symbols.private_constant_fields.applicable_kinds = field -dotnet_naming_symbols.private_constant_fields.applicable_accessibilities = private, protected, protected_internal, private_protected -dotnet_naming_symbols.private_constant_fields.required_modifiers = const - -dotnet_naming_symbols.local_variables.applicable_kinds = local -dotnet_naming_symbols.local_variables.applicable_accessibilities = local -dotnet_naming_symbols.local_variables.required_modifiers = - -dotnet_naming_symbols.local_constants.applicable_kinds = local -dotnet_naming_symbols.local_constants.applicable_accessibilities = local -dotnet_naming_symbols.local_constants.required_modifiers = const - -dotnet_naming_symbols.parameters.applicable_kinds = parameter -dotnet_naming_symbols.parameters.applicable_accessibilities = * -dotnet_naming_symbols.parameters.required_modifiers = +dotnet_naming_symbols.public_fields.required_modifiers = dotnet_naming_symbols.public_constant_fields.applicable_kinds = field dotnet_naming_symbols.public_constant_fields.applicable_accessibilities = public, internal @@ -347,57 +211,193 @@ dotnet_naming_symbols.public_static_readonly_fields.applicable_kinds = field dotnet_naming_symbols.public_static_readonly_fields.applicable_accessibilities = public, internal dotnet_naming_symbols.public_static_readonly_fields.required_modifiers = readonly, static +dotnet_naming_symbols.private_fields.applicable_kinds = field +dotnet_naming_symbols.private_fields.applicable_accessibilities = private, protected, protected_internal, private_protected +dotnet_naming_symbols.private_fields.required_modifiers = + +dotnet_naming_symbols.private_static_fields.applicable_kinds = field +dotnet_naming_symbols.private_static_fields.applicable_accessibilities = private, protected, protected_internal, private_protected +dotnet_naming_symbols.private_static_fields.required_modifiers = static + +dotnet_naming_symbols.private_constant_fields.applicable_kinds = field +dotnet_naming_symbols.private_constant_fields.applicable_accessibilities = private, protected, protected_internal, private_protected +dotnet_naming_symbols.private_constant_fields.required_modifiers = const + dotnet_naming_symbols.private_static_readonly_fields.applicable_kinds = field dotnet_naming_symbols.private_static_readonly_fields.applicable_accessibilities = private, protected, protected_internal, private_protected dotnet_naming_symbols.private_static_readonly_fields.required_modifiers = readonly, static +dotnet_naming_symbols.enums.applicable_kinds = enum +dotnet_naming_symbols.enums.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.enums.required_modifiers = + +dotnet_naming_symbols.local_variables.applicable_kinds = local +dotnet_naming_symbols.local_variables.applicable_accessibilities = local +dotnet_naming_symbols.local_variables.required_modifiers = + +dotnet_naming_symbols.local_constants.applicable_kinds = local +dotnet_naming_symbols.local_constants.applicable_accessibilities = local +dotnet_naming_symbols.local_constants.required_modifiers = const + +dotnet_naming_symbols.parameters.applicable_kinds = parameter +dotnet_naming_symbols.parameters.applicable_accessibilities = * +dotnet_naming_symbols.parameters.required_modifiers = + dotnet_naming_symbols.local_functions.applicable_kinds = local_function dotnet_naming_symbols.local_functions.applicable_accessibilities = * -dotnet_naming_symbols.local_functions.required_modifiers = +dotnet_naming_symbols.local_functions.required_modifiers = -# Naming styles +dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method +dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.non_field_members.required_modifiers = -dotnet_naming_style.pascalcase.required_prefix = -dotnet_naming_style.pascalcase.required_suffix = -dotnet_naming_style.pascalcase.word_separator = +## Naming Styles ## dotnet_naming_style.pascalcase.capitalization = pascal_case +dotnet_naming_style.pascalcase.required_prefix = +dotnet_naming_style.pascalcase.required_suffix = +dotnet_naming_style.pascalcase.word_separator = -dotnet_naming_style.ipascalcase.required_prefix = I -dotnet_naming_style.ipascalcase.required_suffix = -dotnet_naming_style.ipascalcase.word_separator = dotnet_naming_style.ipascalcase.capitalization = pascal_case +dotnet_naming_style.ipascalcase.required_prefix = I +dotnet_naming_style.ipascalcase.required_suffix = +dotnet_naming_style.ipascalcase.word_separator = -dotnet_naming_style.tpascalcase.required_prefix = T -dotnet_naming_style.tpascalcase.required_suffix = -dotnet_naming_style.tpascalcase.word_separator = dotnet_naming_style.tpascalcase.capitalization = pascal_case +dotnet_naming_style.tpascalcase.required_prefix = T +dotnet_naming_style.tpascalcase.required_suffix = +dotnet_naming_style.tpascalcase.word_separator = -dotnet_naming_style._camelcase.required_prefix = _ -dotnet_naming_style._camelcase.required_suffix = -dotnet_naming_style._camelcase.word_separator = -dotnet_naming_style._camelcase.capitalization = camel_case - -dotnet_naming_style.camelcase.required_prefix = -dotnet_naming_style.camelcase.required_suffix = -dotnet_naming_style.camelcase.word_separator = dotnet_naming_style.camelcase.capitalization = camel_case +dotnet_naming_style.camelcase.required_prefix = +dotnet_naming_style.camelcase.required_suffix = +dotnet_naming_style.camelcase.word_separator = + +dotnet_naming_style._camelcase.capitalization = camel_case +dotnet_naming_style._camelcase.required_prefix = _ +dotnet_naming_style._camelcase.required_suffix = +dotnet_naming_style._camelcase.word_separator = -dotnet_naming_style.s_camelcase.required_prefix = s_ -dotnet_naming_style.s_camelcase.required_suffix = -dotnet_naming_style.s_camelcase.word_separator = dotnet_naming_style.s_camelcase.capitalization = camel_case +dotnet_naming_style.s_camelcase.required_prefix = s_ +dotnet_naming_style.s_camelcase.required_suffix = +dotnet_naming_style.s_camelcase.word_separator = -dotnet_diagnostic.SA1623.severity = none -dotnet_diagnostic.SA1624.severity = none - -dotnet_diagnostic.SA1600.severity = suggestion - +# ============================================================ +# C# FILES ONLY +# ============================================================ [*.cs] -# 1. Tell the .NET Formatter to stop injecting a header -file_header_template = unset -# 2. Tell StyleCop to stop requiring a file header (SA1633) -dotnet_diagnostic.SA1633.severity = none +#### Core EditorConfig Options #### +indent_size = 4 +tab_width = 4 +insert_final_newline = false -# 3. Tell the IDE to stop requiring a file header (IDE0073) -dotnet_diagnostic.IDE0073.severity = none \ No newline at end of file +#### var Preferences #### +csharp_style_var_elsewhere = false:silent +csharp_style_var_for_built_in_types = false:silent +csharp_style_var_when_type_is_apparent = false:silent + +#### Expression-Bodied Members #### +csharp_style_expression_bodied_accessors = true:silent +csharp_style_expression_bodied_constructors = false:silent +csharp_style_expression_bodied_indexers = true:silent +csharp_style_expression_bodied_lambdas = true:suggestion +csharp_style_expression_bodied_local_functions = false:silent +csharp_style_expression_bodied_methods = false:silent +csharp_style_expression_bodied_operators = false:silent +csharp_style_expression_bodied_properties = true:silent + +#### Pattern Matching Preferences #### +csharp_style_pattern_matching_over_as_with_null_check = true:suggestion +csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion +csharp_style_prefer_extended_property_pattern = true:suggestion +csharp_style_prefer_not_pattern = true:suggestion +csharp_style_prefer_pattern_matching = true:silent +csharp_style_prefer_switch_expression = true:suggestion + +#### Null-Checking Preferences #### +csharp_style_conditional_delegate_call = true:suggestion + +#### Modifier Preferences #### +csharp_prefer_static_anonymous_function = true:suggestion +csharp_prefer_static_local_function = true:warning +csharp_preferred_modifier_order = public,private,protected,internal,file,const,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,required,volatile,async:suggestion +csharp_style_prefer_readonly_struct = true:suggestion +csharp_style_prefer_readonly_struct_member = true:suggestion + +#### Code-Block Preferences #### +csharp_prefer_braces = true:silent +csharp_prefer_simple_using_statement = true:suggestion +csharp_style_namespace_declarations = file_scoped:suggestion +csharp_style_prefer_method_group_conversion = true:silent +csharp_style_prefer_primary_constructors = true:suggestion +csharp_style_prefer_top_level_statements = true:silent + +#### Expression-Level Preferences #### +csharp_prefer_simple_default_expression = true:suggestion +csharp_style_deconstructed_variable_declaration = true:suggestion +csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion +csharp_style_inlined_variable_declaration = true:suggestion +csharp_style_prefer_index_operator = true:suggestion +csharp_style_prefer_local_over_anonymous_function = true:suggestion +csharp_style_prefer_null_check_over_type_check = true:suggestion +csharp_style_prefer_range_operator = true:suggestion +csharp_style_prefer_tuple_swap = true:suggestion +csharp_style_prefer_utf8_string_literals = true:suggestion +csharp_style_throw_expression = true:suggestion +csharp_style_unused_value_assignment_preference = discard_variable:suggestion +csharp_style_unused_value_expression_statement_preference = discard_variable:silent + +#### Using Directive Preferences #### +csharp_using_directive_placement = inside_namespace:warning + +#### Formatting — New Line Preferences #### +csharp_new_line_before_catch = true +csharp_new_line_before_else = true +csharp_new_line_before_finally = true +csharp_new_line_before_members_in_anonymous_types = true +csharp_new_line_before_members_in_object_initializers = true +csharp_new_line_before_open_brace = all +csharp_new_line_between_query_expression_clauses = true + +#### Formatting — Indentation Preferences #### +csharp_indent_block_contents = true +csharp_indent_braces = false +csharp_indent_case_contents = true +csharp_indent_case_contents_when_block = true +csharp_indent_labels = one_less_than_current +csharp_indent_switch_labels = true + +#### Formatting — Space Preferences #### +csharp_space_after_cast = false +csharp_space_after_colon_in_inheritance_clause = true +csharp_space_after_comma = true +csharp_space_after_dot = false +csharp_space_after_keywords_in_control_flow_statements = true +csharp_space_after_semicolon_in_for_statement = true +csharp_space_around_binary_operators = before_and_after +csharp_space_around_declaration_statements = false +csharp_space_before_colon_in_inheritance_clause = true +csharp_space_before_comma = false +csharp_space_before_dot = false +csharp_space_before_open_square_brackets = false +csharp_space_before_semicolon_in_for_statement = false +csharp_space_between_empty_square_brackets = false +csharp_space_between_method_call_empty_parameter_list_parentheses = false +csharp_space_between_method_call_name_and_opening_parenthesis = false +csharp_space_between_method_call_parameter_list_parentheses = false +csharp_space_between_method_declaration_empty_parameter_list_parentheses = false +csharp_space_between_method_declaration_name_and_open_parenthesis = false +csharp_space_between_method_declaration_parameter_list_parentheses = false +csharp_space_between_parentheses = false +csharp_space_between_square_brackets = false + +#### Formatting — Wrapping Preferences #### +csharp_preserve_single_line_blocks = true +csharp_preserve_single_line_statements = true + +# ============================================================ +# TEST PROJECTS — RELAXED RULES +# ============================================================ +[*.Tests/**/*.cs] +dotnet_diagnostic.SA1600.severity = none \ No newline at end of file diff --git a/Webzine.Documentation/Installation/equipe 1 - dossier de configuration.md b/Webzine.Documentation/Installation/equipe 1 - dossier de configuration.md index 9d202cb..d99576d 100644 --- a/Webzine.Documentation/Installation/equipe 1 - dossier de configuration.md +++ b/Webzine.Documentation/Installation/equipe 1 - dossier de configuration.md @@ -8,8 +8,8 @@ ## Table des modifications -| Date | Auteur | -|------|--------| +| Date | Auteur | +| ----- | ------------- | | 25/03 | Clément Bobin | --- @@ -18,12 +18,12 @@ Avant de lancer l'application, assurez-vous d'avoir installé les outils suivants : -| Outil | Version minimale | Lien | -|-------|-----------------|------| -| .NET SDK | 10.0 | https://dotnet.microsoft.com/download | -| Node.js (optionnel, pour outils front) | 18+ | https://nodejs.org | -| Git | 2.x | https://git-scm.com | -| Un IDE | Visual Studio 2022+ ou Rider | — | +| Outil | Version minimale | Lien | +| -------------------------------------- | ---------------------------- | ------------------------------------- | +| .NET SDK | 10.0 | https://dotnet.microsoft.com/download | +| Node.js (optionnel, pour outils front) | 18+ | https://nodejs.org | +| Git | 2.x | https://git-scm.com | +| Un IDE | Visual Studio 2022+ ou Rider | — | --- @@ -65,6 +65,7 @@ dotnet run ``` L'application est accessible par défaut à : + - **HTTP :** http://localhost:5038 - **HTTPS :** https://localhost:7095 @@ -89,10 +90,10 @@ Le fichier principal de configuration est `Webzine.WebApplication/appsettings.js } ``` -| Propriété | Type | Description | Valeur par défaut | -|-----------|------|-------------|-------------------| -| `NombreDerniereChronique` | int | Nombre de chroniques affichées sur la page d'accueil (section "Derniers titres") | 3 | -| `NombreDeTopTitres` | int | Nombre de titres affichés dans le bloc "Titres les plus populaires" | 3 | +| Propriété | Type | Description | Valeur par défaut | +| ------------------------- | ---- | -------------------------------------------------------------------------------- | ----------------- | +| `NombreDerniereChronique` | int | Nombre de chroniques affichées sur la page d'accueil (section "Derniers titres") | 3 | +| `NombreDeTopTitres` | int | Nombre de titres affichés dans le bloc "Titres les plus populaires" | 3 | Ces valeurs sont injectées dans `AccueilController` via `IConfiguration` et peuvent être modifiées sans recompilation. @@ -106,14 +107,15 @@ La configuration du logging se trouve dans `Webzine.WebApplication/nlog.config`. Les logs sont écrits dans le dossier `/Logs/` avec deux fichiers : -| Fichier | Contenu | -|---------|---------| +| Fichier | Contenu | +| --------------------- | ----------------------------------------------------- | | `nlog-all-{date}.log` | Tous les logs (Debug et supérieur pour l'application) | -| `nlog-own-{date}.log` | Logs applicatifs avec URL de la requête | +| `nlog-own-{date}.log` | Logs applicatifs avec URL de la requête | Les logs de la console sont également activés, utiles lors du développement. **Niveaux configurés :** + - `Webzine.WebApplication.*` → Debug et supérieur - `Microsoft.*` → Warning et supérieur (pour réduire le bruit) - `Microsoft.Hosting.Lifetime*` → Info (pour voir le démarrage de l'appli) @@ -143,18 +145,18 @@ Les tests vérifient les contraintes de validation (annotations DataAnnotations) ## 8. Routes principales -| URL | Contrôleur | Description | -|-----|-----------|-------------| -| `/` | `AccueilController.Index` | Page d'accueil | -| `/artiste/{nom}` | `ArtisteController.Index` | Page d'un artiste | -| `/titre/{id}` | `TitreController.Details` | Détail d'un titre | -| `/titre/style/{style}` | `TitreController.Style` | Titres par style | -| `/recherche` (POST) | `RechercheController.Index` | Résultats de recherche | -| `/Administration/Dashboard` | `DashboardController.Index` | Tableau de bord admin | -| `/Administration/Artiste` | `ArtisteController` (admin) | Gestion des artistes | -| `/Administration/Titre` | `TitreController` (admin) | Gestion des titres | -| `/Administration/Style` | `StyleController` | Gestion des styles | -| `/Administration/Commentaire` | `CommentaireController` | Gestion des commentaires | +| URL | Contrôleur | Description | +| ----------------------------- | --------------------------- | ------------------------ | +| `/` | `AccueilController.Index` | Page d'accueil | +| `/artiste/{nom}` | `ArtisteController.Index` | Page d'un artiste | +| `/titre/{id}` | `TitreController.Details` | Détail d'un titre | +| `/titre/style/{style}` | `TitreController.Style` | Titres par style | +| `/recherche` (POST) | `RechercheController.Index` | Résultats de recherche | +| `/Administration/Dashboard` | `DashboardController.Index` | Tableau de bord admin | +| `/Administration/Artiste` | `ArtisteController` (admin) | Gestion des artistes | +| `/Administration/Titre` | `TitreController` (admin) | Gestion des titres | +| `/Administration/Style` | `StyleController` | Gestion des styles | +| `/Administration/Commentaire` | `CommentaireController` | Gestion des commentaires | --- @@ -168,4 +170,14 @@ En production, positionner : export ASPNETCORE_ENVIRONMENT=Production ``` -Cela désactive les pages d'erreur détaillées et active les optimisations de performance ASP.NET Core. \ No newline at end of file +Cela désactive les pages d'erreur détaillées et active les optimisations de performance ASP.NET Core. + +## Ajout du pre-commit + +Les fichiers présents dans le dossier git_hooks sont à copier dans le dossier caché .git. +Le pre-commit reformatte le code à chaque commit. +Le commit-msg vérifie si le message du commit respecte bien les conventions du cahier des charges: + +- le message référence un ticket +- le message termine par un point +- le message doit faire au moins 10 caractères diff --git a/Webzine.Documentation/StyleCop/stylecop.json b/Webzine.Documentation/StyleCop/stylecop.json index b387567..c2b8c42 100644 --- a/Webzine.Documentation/StyleCop/stylecop.json +++ b/Webzine.Documentation/StyleCop/stylecop.json @@ -2,9 +2,7 @@ "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json", "settings": { "documentationRules": { - "documentInterfaces": false, - "documentInternalElements": false, - "documentExposedElements": false + "documentationCulture": "fr-FR" }, "maintainabilityRules": { "settings": { diff --git a/Webzine.Documentation/git_hooks/commit-msg b/Webzine.Documentation/git_hooks/commit-msg new file mode 100644 index 0000000..eb15525 --- /dev/null +++ b/Webzine.Documentation/git_hooks/commit-msg @@ -0,0 +1,24 @@ +#!/bin/sh + +# Hook: commit-msg +# Validates the commit message format. +# Git passes the path to the temp message file as $1. + +COMMIT_MSG=$(cat "$1") + +if [ ${#COMMIT_MSG} -le 10 ]; then + echo "❌ Erreur : Le message doit faire plus de 10 caractères." + exit 1 +fi + +if ! echo "$COMMIT_MSG" | grep -q "\.$"; then + echo "❌ Erreur : Le commit doit se terminer par un point." + exit 1 +fi + +if ! echo "$COMMIT_MSG" | grep -q "#[0-9]\+"; then + echo "❌ Erreur : Vous devez faire référence à un ticket (ex: #123)." + exit 1 +fi + +exit 0 diff --git a/Webzine.Documentation/git_hooks/pre-commit b/Webzine.Documentation/git_hooks/pre-commit new file mode 100644 index 0000000..5473d88 --- /dev/null +++ b/Webzine.Documentation/git_hooks/pre-commit @@ -0,0 +1,21 @@ +#!/bin/sh + +# Hook: pre-commit +# Runs dotnet format on staged files, then verifies documentation warnings. + +echo "🔧 Running dotnet format..." +dotnet format --severity warn +if [ $? -ne 0 ]; then + echo "❌ Erreur : dotnet format a échoué." + exit 1 +fi +git add -u + +echo "📄 Vérification de la documentation..." +dotnet format style --severity warn --verify-no-changes +if [ $? -ne 0 ]; then + echo "❌ Erreur : Documentation manquante (classes/méthodes non commentées)." + exit 1 +fi + +exit 0 diff --git a/Webzine.Entity.Tests/.editorconfig b/Webzine.Entity.Tests/.editorconfig new file mode 100644 index 0000000..c148d4b --- /dev/null +++ b/Webzine.Entity.Tests/.editorconfig @@ -0,0 +1,2 @@ +[*.cs] +dotnet_diagnostic.SA1600.severity = none \ No newline at end of file diff --git a/Webzine.Repository/DbArtisteRepository.cs b/Webzine.Repository/DbArtisteRepository.cs index 404f7bf..800f5af 100644 --- a/Webzine.Repository/DbArtisteRepository.cs +++ b/Webzine.Repository/DbArtisteRepository.cs @@ -4,8 +4,6 @@ namespace Webzine.Repository { - using System.Data.Common; - using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; diff --git a/Webzine.Repository/DbStyleRepository.cs b/Webzine.Repository/DbStyleRepository.cs index 6d8350b..c350a4f 100644 --- a/Webzine.Repository/DbStyleRepository.cs +++ b/Webzine.Repository/DbStyleRepository.cs @@ -1,11 +1,12 @@ +namespace Webzine.Repository; + using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; + using Webzine.EntitiesContext; using Webzine.Entity; using Webzine.Repository.Contracts; -namespace Webzine.Repository; - /// /// Classe qui implémente le repository pour les styles en utilisant une base de données. /// diff --git a/Webzine.Repository/DbTitreRepository.cs b/Webzine.Repository/DbTitreRepository.cs index 20b90fd..9c0ac04 100644 --- a/Webzine.Repository/DbTitreRepository.cs +++ b/Webzine.Repository/DbTitreRepository.cs @@ -1,11 +1,12 @@ +namespace Webzine.Repository; + using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; + using Webzine.EntitiesContext; using Webzine.Entity; using Webzine.Repository.Contracts; -namespace Webzine.Repository; - /// /// Classe qui implémente le repository pour les titres en utilisant une base de données. /// diff --git a/Webzine.Repository/LocalStyleRepository.cs b/Webzine.Repository/LocalStyleRepository.cs index 02a033d..0b4d16c 100644 --- a/Webzine.Repository/LocalStyleRepository.cs +++ b/Webzine.Repository/LocalStyleRepository.cs @@ -1,9 +1,10 @@ +namespace Webzine.Repository; + using Microsoft.Extensions.Logging; + using Webzine.Entity; using Webzine.Repository.Contracts; -namespace Webzine.Repository; - /// /// Classe qui implémente le repository pour les styles en utilisant une liste locale comme source de données. /// diff --git a/Webzine.Repository/LocalTitreRepository.cs b/Webzine.Repository/LocalTitreRepository.cs index 741bbc8..ff8832c 100644 --- a/Webzine.Repository/LocalTitreRepository.cs +++ b/Webzine.Repository/LocalTitreRepository.cs @@ -1,9 +1,10 @@ +namespace Webzine.Repository; + using Microsoft.Extensions.Logging; + using Webzine.Entity; using Webzine.Repository.Contracts; -namespace Webzine.Repository; - /// /// Classe qui implémente le repository pour les titres en utilisant une liste locale comme source de données. /// diff --git a/Webzine.WebApplication/Areas/Administration/Controllers/ArtisteController.cs b/Webzine.WebApplication/Areas/Administration/Controllers/ArtisteController.cs index d9e2436..fcaf920 100644 --- a/Webzine.WebApplication/Areas/Administration/Controllers/ArtisteController.cs +++ b/Webzine.WebApplication/Areas/Administration/Controllers/ArtisteController.cs @@ -1,10 +1,11 @@ -using Microsoft.AspNetCore.Mvc; +namespace Webzine.WebApplication.Areas.Administration.Controllers; + +using Microsoft.AspNetCore.Mvc; + using Webzine.Entity; using Webzine.Repository.Contracts; using Webzine.WebApplication.Areas.Administration.ViewModels.Artiste; -namespace Webzine.WebApplication.Areas.Administration.Controllers; - /// /// Contrôleur pour la gestion des artistes dans l'administration du webzine. /// diff --git a/Webzine.WebApplication/Areas/Administration/Controllers/DashboardController.cs b/Webzine.WebApplication/Areas/Administration/Controllers/DashboardController.cs index e8e3d89..2f314ad 100644 --- a/Webzine.WebApplication/Areas/Administration/Controllers/DashboardController.cs +++ b/Webzine.WebApplication/Areas/Administration/Controllers/DashboardController.cs @@ -1,10 +1,10 @@ -using System.Diagnostics; +namespace Webzine.WebApplication.Areas.Administration.Controllers; + using Microsoft.AspNetCore.Mvc; + using Webzine.Repository.Contracts; using Webzine.WebApplication.Areas.Administration.ViewModels; -namespace Webzine.WebApplication.Areas.Administration.Controllers; - [Area("Administration")] public class DashboardController : Controller { diff --git a/Webzine.WebApplication/Areas/Administration/Controllers/TitreController.cs b/Webzine.WebApplication/Areas/Administration/Controllers/TitreController.cs index 59f88f0..f703fec 100644 --- a/Webzine.WebApplication/Areas/Administration/Controllers/TitreController.cs +++ b/Webzine.WebApplication/Areas/Administration/Controllers/TitreController.cs @@ -1,11 +1,12 @@ +namespace Webzine.WebApplication.Areas.Administration.Controllers; + using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; + using Webzine.Entity; using Webzine.Repository.Contracts; using Webzine.WebApplication.Areas.Administration.ViewModels.Titre; -namespace Webzine.WebApplication.Areas.Administration.Controllers; - /// /// Contrôleur pour la gestion des titres en administration. Ce contrôleur gère les opérations de création, modification, suppression et affichage des titres dans l'interface d'administration du webzine. Chaque action du contrôleur prépare un ViewModel spécifique pour la vue correspondante, permettant ainsi une séparation claire entre la logique métier et la présentation des données. /// diff --git a/Webzine.WebApplication/Areas/Administration/ViewModels/Titre/AdminTitreForm.cs b/Webzine.WebApplication/Areas/Administration/ViewModels/Titre/AdminTitreForm.cs index 420bf39..5305732 100644 --- a/Webzine.WebApplication/Areas/Administration/ViewModels/Titre/AdminTitreForm.cs +++ b/Webzine.WebApplication/Areas/Administration/ViewModels/Titre/AdminTitreForm.cs @@ -1,7 +1,7 @@ -using Microsoft.AspNetCore.Mvc.Rendering; - namespace Webzine.WebApplication.Areas.Administration.ViewModels.Titre; +using Microsoft.AspNetCore.Mvc.Rendering; + /// /// ViewModel pour la création et la modification d'un titre dans l'administration. /// diff --git a/Webzine.WebApplication/Controllers/ApiController.cs b/Webzine.WebApplication/Controllers/ApiController.cs index 1b1beca..42f72bb 100644 --- a/Webzine.WebApplication/Controllers/ApiController.cs +++ b/Webzine.WebApplication/Controllers/ApiController.cs @@ -1,7 +1,7 @@ -using Microsoft.AspNetCore.Mvc; - namespace Webzine.WebApplication.Controllers; +using Microsoft.AspNetCore.Mvc; + public class ApiController : ControllerBase { private readonly ILogger logger; diff --git a/Webzine.WebApplication/Extensions/RouteConfiguration.cs b/Webzine.WebApplication/Extensions/RouteConfiguration.cs index a3df301..caa0efa 100644 --- a/Webzine.WebApplication/Extensions/RouteConfiguration.cs +++ b/Webzine.WebApplication/Extensions/RouteConfiguration.cs @@ -15,4 +15,4 @@ public static class RouteConfiguration name: "default", pattern: "{controller=Accueil}/{action=Index}/{id?}"); } -} +} \ No newline at end of file diff --git a/Webzine.WebApplication/Program.cs b/Webzine.WebApplication/Program.cs index ae26f07..2a19bd7 100644 --- a/Webzine.WebApplication/Program.cs +++ b/Webzine.WebApplication/Program.cs @@ -1,3 +1,6 @@ +// L'erreur SA1200 (ordre des using directives) est desactivée pour Program.cs +#pragma warning disable SA1200 + using Microsoft.EntityFrameworkCore; using NLog; diff --git a/Webzine.WebApplication/ViewModels/Recherche/RechercheIndexViewModel.cs b/Webzine.WebApplication/ViewModels/Recherche/RechercheIndexViewModel.cs index 177125d..1d7b246 100644 --- a/Webzine.WebApplication/ViewModels/Recherche/RechercheIndexViewModel.cs +++ b/Webzine.WebApplication/ViewModels/Recherche/RechercheIndexViewModel.cs @@ -1,7 +1,7 @@ -using Webzine.WebApplication.ViewModels.Titre; - namespace Webzine.WebApplication.ViewModels.Recherche; +using Webzine.WebApplication.ViewModels.Titre; + /// /// ViewModel pour afficher les resultats de recherche d'artistes et de titres. /// diff --git a/Webzine.WebApplication/ViewModels/Titre/TitreComment.cs b/Webzine.WebApplication/ViewModels/Titre/TitreComment.cs index 1281c77..e2bedc7 100644 --- a/Webzine.WebApplication/ViewModels/Titre/TitreComment.cs +++ b/Webzine.WebApplication/ViewModels/Titre/TitreComment.cs @@ -1,7 +1,7 @@ -using System.ComponentModel.DataAnnotations; - namespace Webzine.WebApplication.ViewModels.Titre; +using System.ComponentModel.DataAnnotations; + /// /// Classe représentant un commentaire sur un titre, utilisée pour la validation des données lors de la soumission d'un commentaire. /// diff --git a/Webzine.WebApplication/ViewModels/Titre/TitreContent.cs b/Webzine.WebApplication/ViewModels/Titre/TitreContent.cs index 43d46a1..52d561e 100644 --- a/Webzine.WebApplication/ViewModels/Titre/TitreContent.cs +++ b/Webzine.WebApplication/ViewModels/Titre/TitreContent.cs @@ -1,7 +1,7 @@ -using Webzine.Entity; - namespace Webzine.WebApplication.ViewModels.Titre; +using Webzine.Entity; + /// /// Contient les détails d'un titre, ainsi que les commentaires associés. /// From 6f009fcc3d8bcbb415eec2d2f3642ff46efd0eea Mon Sep 17 00:00:00 2001 From: Loic Masi Date: Tue, 31 Mar 2026 13:06:30 +0200 Subject: [PATCH 05/22] =?UTF-8?q?#154=20:=20Premi=C3=A8re=20optimisation?= =?UTF-8?q?=20de=20la=20recherche?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Webzine.Repository/DbArtisteRepository.cs | 2 +- Webzine.Repository/DbTitreRepository.cs | 1 + .../Controllers/RechercheController.cs | 40 ++------ .../Recherche/RechercheIndexViewModel.cs | 36 +++---- .../Views/Recherche/Index.cshtml | 93 +++++++++---------- wwwroot/css/site.css | 0 6 files changed, 72 insertions(+), 100 deletions(-) delete mode 100644 wwwroot/css/site.css diff --git a/Webzine.Repository/DbArtisteRepository.cs b/Webzine.Repository/DbArtisteRepository.cs index 404f7bf..2546bc7 100644 --- a/Webzine.Repository/DbArtisteRepository.cs +++ b/Webzine.Repository/DbArtisteRepository.cs @@ -120,7 +120,7 @@ namespace Webzine.Repository try { // .AsNoTracking() rend la requête beaucoup plus rapide pour de la lecture - var artistes = this.context.Artistes.AsNoTracking().ToList(); + var artistes = this.context.Artistes.AsNoTracking().Include(t => t.Titres).ToList(); this.logger.LogDebug("{Count} artistes récupérés de la base.", artistes.Count); return artistes; } diff --git a/Webzine.Repository/DbTitreRepository.cs b/Webzine.Repository/DbTitreRepository.cs index 20b90fd..66ebec5 100644 --- a/Webzine.Repository/DbTitreRepository.cs +++ b/Webzine.Repository/DbTitreRepository.cs @@ -242,6 +242,7 @@ public class DbTitreRepository : ITitreRepository .Include(t => t.Styles) .Where(t => t.Libelle.ToLower().Contains(mot.ToLower())) .OrderBy(t => t.Libelle) + .AsNoTracking() .ToList(); this.logger.LogDebug("{Count} titres trouvés correspondant à '{Mot}'", titres.Count, mot); diff --git a/Webzine.WebApplication/Controllers/RechercheController.cs b/Webzine.WebApplication/Controllers/RechercheController.cs index 9d6f7e2..061c9d6 100644 --- a/Webzine.WebApplication/Controllers/RechercheController.cs +++ b/Webzine.WebApplication/Controllers/RechercheController.cs @@ -8,52 +8,32 @@ namespace Webzine.WebApplication.Controllers using Webzine.Repository.Contracts; using Webzine.WebApplication.ViewModels.Recherche; - using Webzine.WebApplication.ViewModels.Titre; - [Route("recherche")] public class RechercheController : Controller { private readonly ILogger logger; private readonly ITitreRepository titreRepository; + private readonly IArtisteRepository artisteRepository; - public RechercheController(ILogger logger, ITitreRepository titreRepository) + public RechercheController( + ILogger logger, + ITitreRepository titreRepository, + IArtisteRepository artisteRepository) { this.logger = logger; this.titreRepository = titreRepository; + this.artisteRepository = artisteRepository; } - [HttpPost("")] public IActionResult Index(string mot) { this.logger.LogInformation("Recherche artistes/titres pour le mot : {Mot}.", mot); - var titres = this.titreRepository.Search(mot) - .Concat(this.titreRepository.SearchByStyle(mot)) - .DistinctBy(t => t.IdTitre) - .OrderBy(t => t.Libelle) - .Select(t => new TitreStyleItem - { - IdTitre = t.IdTitre, - Libelle = t.Libelle, - ArtisteNom = t.Artiste?.Nom, - UrlJaquette = t.UrlJaquette, - Duree = t.Duree, - }) - .ToList(); + var titres = this.titreRepository.Search(mot).ToList(); - var artistes = this.titreRepository.FindAll() - .Select(t => t.Artiste) - .Where(a => a != null - && !string.IsNullOrWhiteSpace(a.Nom) - && !string.IsNullOrWhiteSpace(mot) - && a.Nom.Contains(mot, StringComparison.OrdinalIgnoreCase)) - .DistinctBy(a => a!.IdArtiste) - .OrderBy(a => a!.Nom) - .Select(a => new RechercheArtisteItem - { - Nom = a!.Nom, - NombreDeTitres = a.Titres?.Count ?? 0, - }) + var artistes = this.artisteRepository + .FindAll() + .Where(a => a.Nom.ToLower().Contains(mot.ToLower())) .ToList(); var vm = new RechercheIndexViewModel diff --git a/Webzine.WebApplication/ViewModels/Recherche/RechercheIndexViewModel.cs b/Webzine.WebApplication/ViewModels/Recherche/RechercheIndexViewModel.cs index 177125d..7a53090 100644 --- a/Webzine.WebApplication/ViewModels/Recherche/RechercheIndexViewModel.cs +++ b/Webzine.WebApplication/ViewModels/Recherche/RechercheIndexViewModel.cs @@ -1,24 +1,24 @@ -using Webzine.WebApplication.ViewModels.Titre; - -namespace Webzine.WebApplication.ViewModels.Recherche; - -/// -/// ViewModel pour afficher les resultats de recherche d'artistes et de titres. -/// -public class RechercheIndexViewModel +namespace Webzine.WebApplication.ViewModels.Recherche { + using Webzine.Entity; /// - /// Mot saisi dans le formulaire. + /// ViewModel pour afficher les resultats de recherche d'artistes et de titres. /// - public string? Mot { get; set; } + public class RechercheIndexViewModel + { + /// + /// Mot saisi dans le formulaire. + /// + public string? Mot { get; set; } - /// - /// Artistes trouves. - /// - public List Artistes { get; set; } = new (); + /// + /// Artistes trouves. + /// + public List Artistes { get; set; } = new (); - /// - /// Titres trouves. - /// - public List Titres { get; set; } = new (); + /// + /// Titres trouves. + /// + public List Titres { get; set; } = new (); + } } \ No newline at end of file diff --git a/Webzine.WebApplication/Views/Recherche/Index.cshtml b/Webzine.WebApplication/Views/Recherche/Index.cshtml index cb5fca6..53e3853 100644 --- a/Webzine.WebApplication/Views/Recherche/Index.cshtml +++ b/Webzine.WebApplication/Views/Recherche/Index.cshtml @@ -10,74 +10,65 @@

Resultats pour "@Model.Mot"


+

Artistes

- @if (string.IsNullOrWhiteSpace(Model.Mot)) + @if (!Model.Artistes.Any()) {
- Saisissez un mot-cle pour lancer une recherche. +

Aucun artiste n'a t trouv.

} - else if (!Model.Artistes.Any() && !Model.Titres.Any()) + + @foreach (var artiste in Model.Artistes) + { +
+ + @artiste.Nom + + (@artiste.Titres.Count titre(s)) +
+ } +

Titres

+ + @if (!Model.Titres.Any()) {
- Aucun artiste ni titre ne correspond a votre recherche. +

Aucun titre n'a t trouv.

} - else - { - @if (Model.Artistes.Any()) - { -

Artistes

- @foreach (var artiste in Model.Artistes) - { -
+ @foreach (var titre in Model.Titres) + { +
+ + @titre.Libelle + + +
+ - } - } - - @if (Model.Titres.Any()) - { -

Titres

- - @foreach (var titre in Model.Titres) - { -
+ - - @titre.Libelle + asp-route-id="@titre.IdTitre"> + @titre.Libelle - -
- - -
- Duree : @TimeSpan.FromSeconds(titre.Duree).ToString(@"mm\:ss") -
-
- } - } + +
+ Duree : @TimeSpan.FromSeconds(titre.Duree).ToString(@"mm\:ss") +
+
+
}
diff --git a/wwwroot/css/site.css b/wwwroot/css/site.css deleted file mode 100644 index e69de29..0000000 From e5ecf75f496324ab2483a585da2a709b54d7a4b1 Mon Sep 17 00:00:00 2001 From: Loic Masi Date: Tue, 31 Mar 2026 13:30:47 +0200 Subject: [PATCH 06/22] =?UTF-8?q?#154=20:=20D=C3=A9placement=20de=20la=20r?= =?UTF-8?q?echerche=20des=20artistes=20dans=20les=20RepositoryArtiste.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IArtisteRepository.cs | 7 +++++++ Webzine.Repository/DbArtisteRepository.cs | 20 +++++++++++++++++-- Webzine.Repository/LocalArtisteRepository.cs | 8 ++++++++ .../Controllers/RechercheController.cs | 7 ++----- .../Recherche/RechercheIndexViewModel.cs | 4 ++-- 5 files changed, 37 insertions(+), 9 deletions(-) diff --git a/Webzine.Repository.Contracts/IArtisteRepository.cs b/Webzine.Repository.Contracts/IArtisteRepository.cs index 1ab6e83..49754b4 100644 --- a/Webzine.Repository.Contracts/IArtisteRepository.cs +++ b/Webzine.Repository.Contracts/IArtisteRepository.cs @@ -44,5 +44,12 @@ namespace Webzine.Repository.Contracts /// /// L'artiste à mettre à jour. void Update(Artiste artiste); + + /// + /// Récupérer une liste d'artiste à partir d'une recherche. + /// + /// Nom de l'artiste. + /// IEnumarble qui contient la chaine de caractere. + IEnumerable Search(string nom); } } \ No newline at end of file diff --git a/Webzine.Repository/DbArtisteRepository.cs b/Webzine.Repository/DbArtisteRepository.cs index 2546bc7..f12617c 100644 --- a/Webzine.Repository/DbArtisteRepository.cs +++ b/Webzine.Repository/DbArtisteRepository.cs @@ -4,8 +4,6 @@ namespace Webzine.Repository { - using System.Data.Common; - using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; @@ -156,5 +154,23 @@ namespace Webzine.Repository throw; } } + + /// + public IEnumerable Search(string mot) + { + try + { + var artiste = this.context.Artistes + .Where(a => a.Nom.ToLower().Contains(mot.ToLower())) + .Include(t => t.Titres) + .AsNoTracking() + .ToList(); + return artiste; + } + catch (Exception ex) + { + throw new Exception("Erreur lors de la recherche d'artiste {error}", ex); + } + } } } \ No newline at end of file diff --git a/Webzine.Repository/LocalArtisteRepository.cs b/Webzine.Repository/LocalArtisteRepository.cs index 67ebabf..69021c5 100644 --- a/Webzine.Repository/LocalArtisteRepository.cs +++ b/Webzine.Repository/LocalArtisteRepository.cs @@ -85,5 +85,13 @@ namespace Webzine.Repository { throw new NotSupportedException("Mode Local"); } + + /// + public IEnumerable Search(string mot) + { + return this.dataStore.Artistes + .Where(a => a.Nom.ToLower().Contains(mot.ToLower())) + .ToList(); + } } } \ No newline at end of file diff --git a/Webzine.WebApplication/Controllers/RechercheController.cs b/Webzine.WebApplication/Controllers/RechercheController.cs index 061c9d6..729cf64 100644 --- a/Webzine.WebApplication/Controllers/RechercheController.cs +++ b/Webzine.WebApplication/Controllers/RechercheController.cs @@ -29,12 +29,9 @@ namespace Webzine.WebApplication.Controllers { this.logger.LogInformation("Recherche artistes/titres pour le mot : {Mot}.", mot); - var titres = this.titreRepository.Search(mot).ToList(); + var titres = this.titreRepository.Search(mot); - var artistes = this.artisteRepository - .FindAll() - .Where(a => a.Nom.ToLower().Contains(mot.ToLower())) - .ToList(); + var artistes = this.artisteRepository.Search(mot); var vm = new RechercheIndexViewModel { diff --git a/Webzine.WebApplication/ViewModels/Recherche/RechercheIndexViewModel.cs b/Webzine.WebApplication/ViewModels/Recherche/RechercheIndexViewModel.cs index 7a53090..3132306 100644 --- a/Webzine.WebApplication/ViewModels/Recherche/RechercheIndexViewModel.cs +++ b/Webzine.WebApplication/ViewModels/Recherche/RechercheIndexViewModel.cs @@ -14,11 +14,11 @@ namespace Webzine.WebApplication.ViewModels.Recherche /// /// Artistes trouves. /// - public List Artistes { get; set; } = new (); + public IEnumerable Artistes { get; set; } = new List(); /// /// Titres trouves. /// - public List Titres { get; set; } = new (); + public IEnumerable Titres { get; set; } = new List(); } } \ No newline at end of file From f573ac2455d32101bd54422b8f9d8232b866e5f6 Mon Sep 17 00:00:00 2001 From: "josephine.vetu" Date: Tue, 31 Mar 2026 13:41:04 +0200 Subject: [PATCH 07/22] #144 Ajout de la date et de mon nom sur la table des modifications. Modification de stylecop pour correspondre au cahier des charges. --- .../Installation/equipe 1 - dossier de configuration.md | 1 + Webzine.Documentation/StyleCop/stylecop.json | 8 ++------ .../ViewModels/Commentaire/CommentaireViewModel.cs | 4 ++-- .../ViewModels/Styles/StyleCreateViewModel.cs | 4 ++-- .../ViewModels/Styles/StyleDeleteViewModel.cs | 4 ++-- .../ViewModels/Styles/StyleEditViewModel.cs | 4 ++-- Webzine.WebApplication/Controllers/RechercheController.cs | 4 ++-- Webzine.WebApplication/Controllers/TitreController.cs | 4 ++-- 8 files changed, 15 insertions(+), 18 deletions(-) diff --git a/Webzine.Documentation/Installation/equipe 1 - dossier de configuration.md b/Webzine.Documentation/Installation/equipe 1 - dossier de configuration.md index d99576d..ee3333a 100644 --- a/Webzine.Documentation/Installation/equipe 1 - dossier de configuration.md +++ b/Webzine.Documentation/Installation/equipe 1 - dossier de configuration.md @@ -11,6 +11,7 @@ | Date | Auteur | | ----- | ------------- | | 25/03 | Clément Bobin | +| 31/03 | Joséphine Vetu | --- diff --git a/Webzine.Documentation/StyleCop/stylecop.json b/Webzine.Documentation/StyleCop/stylecop.json index c2b8c42..52ce63b 100644 --- a/Webzine.Documentation/StyleCop/stylecop.json +++ b/Webzine.Documentation/StyleCop/stylecop.json @@ -2,12 +2,8 @@ "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json", "settings": { "documentationRules": { + "companyName": "Equipe 1 - BOBIN, MASI, NODON, VETU", "documentationCulture": "fr-FR" - }, - "maintainabilityRules": { - "settings": { - "commonWords": [ "Obtient", "définit" ] - } + } } } -} diff --git a/Webzine.WebApplication/Areas/Administration/ViewModels/Commentaire/CommentaireViewModel.cs b/Webzine.WebApplication/Areas/Administration/ViewModels/Commentaire/CommentaireViewModel.cs index 722612d..1ca07fd 100644 --- a/Webzine.WebApplication/Areas/Administration/ViewModels/Commentaire/CommentaireViewModel.cs +++ b/Webzine.WebApplication/Areas/Administration/ViewModels/Commentaire/CommentaireViewModel.cs @@ -1,5 +1,5 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. +// +// Copyright (c) Equipe 1 - BOBIN, MASI, NODON, VETU. All rights reserved. // namespace Webzine.WebApplication.Areas.Administration.ViewModels.Commentaire diff --git a/Webzine.WebApplication/Areas/Administration/ViewModels/Styles/StyleCreateViewModel.cs b/Webzine.WebApplication/Areas/Administration/ViewModels/Styles/StyleCreateViewModel.cs index e744af0..3cd24d4 100644 --- a/Webzine.WebApplication/Areas/Administration/ViewModels/Styles/StyleCreateViewModel.cs +++ b/Webzine.WebApplication/Areas/Administration/ViewModels/Styles/StyleCreateViewModel.cs @@ -1,5 +1,5 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. +// +// Copyright (c) Equipe 1 - BOBIN, MASI, NODON, VETU. All rights reserved. // namespace Webzine.WebApplication.Areas.Administration.ViewModels.Style diff --git a/Webzine.WebApplication/Areas/Administration/ViewModels/Styles/StyleDeleteViewModel.cs b/Webzine.WebApplication/Areas/Administration/ViewModels/Styles/StyleDeleteViewModel.cs index 0b882a3..fc94e54 100644 --- a/Webzine.WebApplication/Areas/Administration/ViewModels/Styles/StyleDeleteViewModel.cs +++ b/Webzine.WebApplication/Areas/Administration/ViewModels/Styles/StyleDeleteViewModel.cs @@ -1,5 +1,5 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. +// +// Copyright (c) Equipe 1 - BOBIN, MASI, NODON, VETU. All rights reserved. // namespace Webzine.WebApplication.Areas.Administration.ViewModels.Style diff --git a/Webzine.WebApplication/Areas/Administration/ViewModels/Styles/StyleEditViewModel.cs b/Webzine.WebApplication/Areas/Administration/ViewModels/Styles/StyleEditViewModel.cs index c252e66..9095f60 100644 --- a/Webzine.WebApplication/Areas/Administration/ViewModels/Styles/StyleEditViewModel.cs +++ b/Webzine.WebApplication/Areas/Administration/ViewModels/Styles/StyleEditViewModel.cs @@ -1,5 +1,5 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. +// +// Copyright (c) Equipe 1 - BOBIN, MASI, NODON, VETU. All rights reserved. // namespace Webzine.WebApplication.Areas.Administration.ViewModels.Style diff --git a/Webzine.WebApplication/Controllers/RechercheController.cs b/Webzine.WebApplication/Controllers/RechercheController.cs index 9d6f7e2..4676c9d 100644 --- a/Webzine.WebApplication/Controllers/RechercheController.cs +++ b/Webzine.WebApplication/Controllers/RechercheController.cs @@ -1,5 +1,5 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. +// +// Copyright (c) Equipe 1 - BOBIN, MASI, NODON, VETU. All rights reserved. // namespace Webzine.WebApplication.Controllers diff --git a/Webzine.WebApplication/Controllers/TitreController.cs b/Webzine.WebApplication/Controllers/TitreController.cs index 76ad52b..01b1239 100644 --- a/Webzine.WebApplication/Controllers/TitreController.cs +++ b/Webzine.WebApplication/Controllers/TitreController.cs @@ -1,5 +1,5 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. +// +// Copyright (c) Equipe 1 - BOBIN, MASI, NODON, VETU. All rights reserved. // namespace Webzine.WebApplication.Controllers From 6fe21ae8fb7518c6daf0800f61e87606e87b26c4 Mon Sep 17 00:00:00 2001 From: mirage <119869686+ClementBobin@users.noreply.github.com> Date: Tue, 31 Mar 2026 13:44:56 +0200 Subject: [PATCH 08/22] feat: add caching for NuGet packages and build output in CI workflow --- .gitea/workflows/pr-endpoint-check.yml | 61 ++++++++++++++------------ 1 file changed, 33 insertions(+), 28 deletions(-) diff --git a/.gitea/workflows/pr-endpoint-check.yml b/.gitea/workflows/pr-endpoint-check.yml index 427f687..a3fdeae 100644 --- a/.gitea/workflows/pr-endpoint-check.yml +++ b/.gitea/workflows/pr-endpoint-check.yml @@ -13,19 +13,31 @@ jobs: - name: Configure appsettings for CI run: | - # Find the appsettings.json file APPSETTINGS_PATH="Webzine.WebApplication/appsettings.json" - - # Backup original file cp $APPSETTINGS_PATH $APPSETTINGS_PATH.bak - - # Use jq to modify the JSON jq '.UseDatabase = true | .IsSQLite = true' $APPSETTINGS_PATH > $APPSETTINGS_PATH.tmp mv $APPSETTINGS_PATH.tmp $APPSETTINGS_PATH - echo "Updated appsettings.json:" cat $APPSETTINGS_PATH + - name: Cache NuGet packages + uses: actions/cache@v3 + with: + path: ~/.nuget/packages + key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/*.sln') }} + restore-keys: | + ${{ runner.os }}-nuget- + + - name: Cache build output + uses: actions/cache@v3 + with: + path: | + **/bin + **/obj + key: ${{ runner.os }}-build-${{ hashFiles('**/*.cs', '**/*.csproj') }} + restore-keys: | + ${{ runner.os }}-build- + - name: Setup .NET 10 uses: actions/setup-dotnet@v4 with: @@ -65,24 +77,22 @@ jobs: chmod +x scripts/test-endpoints.sh bash scripts/test-endpoints.sh http://localhost:5038 1000 2>&1 | tee /tmp/webzine_endpoint_output.txt EXIT_CODE=${PIPESTATUS[0]} - - # Count failures + FAIL_COUNT=$(grep -cE "^\[ÉCHEC\]" /tmp/webzine_endpoint_output.txt 2>/dev/null || echo 0) SLOW_COUNT=$(grep -cE "^\[LENT\]" /tmp/webzine_endpoint_output.txt 2>/dev/null || echo 0) - + echo "failed=$FAIL_COUNT" >> "$GITHUB_OUTPUT" echo "slow=$SLOW_COUNT" >> "$GITHUB_OUTPUT" - - # Échoue s’il y a DES problèmes (échecs OU lents) + if [ $FAIL_COUNT -gt 0 ] || [ $SLOW_COUNT -gt 0 ]; then echo "❌ Performance check failed: $FAIL_COUNT endpoint(s) failed, $SLOW_COUNT endpoint(s) exceeded threshold (1000ms)" exit 1 fi - + echo "✅ All endpoints passed performance check (< 1000ms)" - name: Post performance report as PR comment - if: always() # Always post comment, even on failure + if: always() env: GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} GITEA_SERVER_URL: ${{ gitea.server_url }} @@ -92,20 +102,15 @@ jobs: RAW_REPORT=$(cat /tmp/webzine_endpoint_output.txt 2>/dev/null || echo "Aucune sortie capturée.") FAILED_COUNT="${{ steps.perf_test.outputs.failed }}" SLOW_COUNT="${{ steps.perf_test.outputs.slow }}" - - # Determine if the check passed or failed + if [ "$FAILED_COUNT" -gt 0 ] || [ "$SLOW_COUNT" -gt 0 ]; then STATUS_HEADER="❌ **PERFORMANCE CHECK FAILED**" - STATUS_ICON="❌" else STATUS_HEADER="✅ **PERFORMANCE CHECK PASSED**" - STATUS_ICON="✅" fi - - # Convert report to Markdown with colors + CLEAN_REPORT=$(echo "$RAW_REPORT" | sed 's/\x1b\[[0-9;]*m//g') - - # Generate formatted report + FORMATTED_REPORT=$(echo "$CLEAN_REPORT" | sed \ -e 's/^\[OK\] /✅ /' \ -e 's/^\[LENT\] /⚠️ /' \ @@ -120,23 +125,23 @@ jobs: -e 's/^\(⚠️ ENDPOINTS LENTS.*\)$/\n### \1/' \ -e 's/^\(❌ ENDPOINTS EN ÉCHEC.*\)$/\n### \1/' \ -e 's/^\(La PR doit.*\)$/\n**❌ \1**/') - + BODY=$(cat </dev/null || echo 0) + - ✅ Endpoints rapides: $(grep -c "^\[OK\]" /tmp/webzine_endpoint_output.txt 2>/dev/null || echo 0) - ⚠️ Endpoints lents (>1000ms): $SLOW_COUNT - ❌ Endpoints en échec: $FAILED_COUNT - + **Vérifié par**: Workflow PR Endpoint Performance EOF ) - + curl -s -X POST \ -H "Authorization: token $GITEA_TOKEN" \ -H "Content-Type: application/json" \ From 0522c2127f627525e4fbbe092f847d6beb2b3cea Mon Sep 17 00:00:00 2001 From: mirage <119869686+ClementBobin@users.noreply.github.com> Date: Tue, 31 Mar 2026 13:51:37 +0200 Subject: [PATCH 09/22] feat: add caching for .NET SDK and optimize NuGet package caching in CI workflow --- .gitea/workflows/pr-endpoint-check.yml | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/.gitea/workflows/pr-endpoint-check.yml b/.gitea/workflows/pr-endpoint-check.yml index a3fdeae..1aba34b 100644 --- a/.gitea/workflows/pr-endpoint-check.yml +++ b/.gitea/workflows/pr-endpoint-check.yml @@ -20,6 +20,14 @@ jobs: echo "Updated appsettings.json:" cat $APPSETTINGS_PATH + - name: Cache .NET SDK + uses: actions/cache@v3 + with: + path: | + ~/.dotnet + /usr/share/dotnet + key: ${{ runner.os }}-dotnet-10.0.x + - name: Cache NuGet packages uses: actions/cache@v3 with: @@ -28,16 +36,6 @@ jobs: restore-keys: | ${{ runner.os }}-nuget- - - name: Cache build output - uses: actions/cache@v3 - with: - path: | - **/bin - **/obj - key: ${{ runner.os }}-build-${{ hashFiles('**/*.cs', '**/*.csproj') }} - restore-keys: | - ${{ runner.os }}-build- - - name: Setup .NET 10 uses: actions/setup-dotnet@v4 with: @@ -131,13 +129,6 @@ jobs: $FORMATTED_REPORT - --- - **Seuil**: 1000ms - **Statistiques**: - - ✅ Endpoints rapides: $(grep -c "^\[OK\]" /tmp/webzine_endpoint_output.txt 2>/dev/null || echo 0) - - ⚠️ Endpoints lents (>1000ms): $SLOW_COUNT - - ❌ Endpoints en échec: $FAILED_COUNT - **Vérifié par**: Workflow PR Endpoint Performance EOF ) From c74d629782734ef3a3be1afed5f1bfd257c76687 Mon Sep 17 00:00:00 2001 From: Loic Masi Date: Tue, 31 Mar 2026 14:21:02 +0200 Subject: [PATCH 10/22] #160 : Patch du bug sur la page de recherche. --- Webzine.Repository.Contracts/IArtisteRepository.cs | 2 +- .../ViewModels/Recherche/RechercheIndexViewModel.cs | 1 + Webzine.WebApplication/Views/Shared/_Header.cshtml | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Webzine.Repository.Contracts/IArtisteRepository.cs b/Webzine.Repository.Contracts/IArtisteRepository.cs index 49754b4..bc13f76 100644 --- a/Webzine.Repository.Contracts/IArtisteRepository.cs +++ b/Webzine.Repository.Contracts/IArtisteRepository.cs @@ -49,7 +49,7 @@ namespace Webzine.Repository.Contracts /// Récupérer une liste d'artiste à partir d'une recherche. /// /// Nom de l'artiste. - /// IEnumarble qui contient la chaine de caractere. + /// IEnumarble. qui contient la chaine de caractere. IEnumerable Search(string nom); } } \ No newline at end of file diff --git a/Webzine.WebApplication/ViewModels/Recherche/RechercheIndexViewModel.cs b/Webzine.WebApplication/ViewModels/Recherche/RechercheIndexViewModel.cs index 3132306..c1da754 100644 --- a/Webzine.WebApplication/ViewModels/Recherche/RechercheIndexViewModel.cs +++ b/Webzine.WebApplication/ViewModels/Recherche/RechercheIndexViewModel.cs @@ -1,6 +1,7 @@ namespace Webzine.WebApplication.ViewModels.Recherche { using Webzine.Entity; + /// /// ViewModel pour afficher les resultats de recherche d'artistes et de titres. /// diff --git a/Webzine.WebApplication/Views/Shared/_Header.cshtml b/Webzine.WebApplication/Views/Shared/_Header.cshtml index f538faf..ad2f930 100644 --- a/Webzine.WebApplication/Views/Shared/_Header.cshtml +++ b/Webzine.WebApplication/Views/Shared/_Header.cshtml @@ -61,7 +61,7 @@ -
+
Date: Tue, 31 Mar 2026 14:41:31 +0200 Subject: [PATCH 11/22] =?UTF-8?q?#154=20:=20Ajout=20de=20commentaire=20en?= =?UTF-8?q?=20suppression=20d'un=20fichier=20inutilis=C3=A9.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Webzine.Repository/DbArtisteRepository.cs | 4 ++++ .../Controllers/RechercheController.cs | 9 +++++++++ .../Recherche/RechercheArtisteItem.cs | 17 ----------------- 3 files changed, 13 insertions(+), 17 deletions(-) delete mode 100644 Webzine.WebApplication/ViewModels/Recherche/RechercheArtisteItem.cs diff --git a/Webzine.Repository/DbArtisteRepository.cs b/Webzine.Repository/DbArtisteRepository.cs index f12617c..fa6ff18 100644 --- a/Webzine.Repository/DbArtisteRepository.cs +++ b/Webzine.Repository/DbArtisteRepository.cs @@ -160,6 +160,10 @@ namespace Webzine.Repository { try { + // Récupération des artistes et des titres + // qui leurs sont associés. + // ajout de 'ToLower' pour ne pas être sensible à la casse. + // NoTracking car action de lecture seulement. var artiste = this.context.Artistes .Where(a => a.Nom.ToLower().Contains(mot.ToLower())) .Include(t => t.Titres) diff --git a/Webzine.WebApplication/Controllers/RechercheController.cs b/Webzine.WebApplication/Controllers/RechercheController.cs index cb8e734..2d5c4b9 100644 --- a/Webzine.WebApplication/Controllers/RechercheController.cs +++ b/Webzine.WebApplication/Controllers/RechercheController.cs @@ -25,14 +25,23 @@ namespace Webzine.WebApplication.Controllers this.artisteRepository = artisteRepository; } + /// + /// Affichage de la page Recherche depuis le header de l'app. + /// + /// Nom d'artiste ou de titre. + /// Page de recherche avec les rsultats. public IActionResult Index(string mot) { + // Logger la recherche. this.logger.LogInformation("Recherche artistes/titres pour le mot : {Mot}.", mot); + // Recherche des titres. var titres = this.titreRepository.Search(mot); + // Recherche des artistes. var artistes = this.artisteRepository.Search(mot); + // Paramtres a retourner la vue. var vm = new RechercheIndexViewModel { Mot = mot, diff --git a/Webzine.WebApplication/ViewModels/Recherche/RechercheArtisteItem.cs b/Webzine.WebApplication/ViewModels/Recherche/RechercheArtisteItem.cs deleted file mode 100644 index d179c3f..0000000 --- a/Webzine.WebApplication/ViewModels/Recherche/RechercheArtisteItem.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace Webzine.WebApplication.ViewModels.Recherche; - -/// -/// ViewModel pour afficher un artiste dans les resultats de recherche. -/// -public class RechercheArtisteItem -{ - /// - /// Nom de l'artiste. - /// - public string? Nom { get; set; } - - /// - /// Nombre de titres associes a l'artiste. - /// - public int NombreDeTitres { get; set; } -} \ No newline at end of file From fa778a8711dd2c017ac9374bb30505d73291a471 Mon Sep 17 00:00:00 2001 From: mirage <119869686+ClementBobin@users.noreply.github.com> Date: Tue, 31 Mar 2026 14:42:43 +0200 Subject: [PATCH 12/22] =?UTF-8?q?refactor:=20mettre=20=C3=A0=20jour=20la?= =?UTF-8?q?=20cha=C3=AEne=20de=20connexion=20PostgreSQL=20dans=20appsettin?= =?UTF-8?q?gs.json?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Webzine.WebApplication/appsettings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Webzine.WebApplication/appsettings.json b/Webzine.WebApplication/appsettings.json index ac0f745..20bd894 100644 --- a/Webzine.WebApplication/appsettings.json +++ b/Webzine.WebApplication/appsettings.json @@ -11,7 +11,7 @@ }, "ConnectionStrings": { "SqliteConnection": "Data Source=Data/webzine.sqlite", - "PostGreSQLConnection": "Host=192.168.60.50;Port=5432;Username=postgres;Password=BcS4e6DHr2NgVrnPomVI;Database=webzine_prod" + "PostGreSQLConnection": "Host=localhost;Port=5432;Username=admin;Password=admin123;Database=webzine_db" }, "AllowedHosts": "*" } \ No newline at end of file From bf4b12997c6f5c29d63bf0d8df76bb32e3e0fc6b Mon Sep 17 00:00:00 2001 From: Loic Masi Date: Tue, 31 Mar 2026 16:48:40 +0200 Subject: [PATCH 13/22] =?UTF-8?q?#162=20:=20Patch=20bug=20lors=20de=20reto?= =?UTF-8?q?ur=20sur=20une=20page=20"Delete"=20apr=C3=A8s=20la=20suppressio?= =?UTF-8?q?n=20d'un=20=C3=A9l=C3=A9ment.=20Redirection=20sur=20la=20page?= =?UTF-8?q?=20"Index"=20en=20cas=20de=20retour=20en=20arri=C3=A8re=20de=20?= =?UTF-8?q?la=20part=20d'un=20utilisateur.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Webzine.Repository/DbArtisteRepository.cs | 4 ++-- Webzine.Repository/DbTitreRepository.cs | 2 -- .../Areas/Administration/Controllers/ArtisteController.cs | 6 ++++++ .../Administration/Controllers/CommentaireController.cs | 5 +++++ .../Areas/Administration/Controllers/TitreController.cs | 5 +++++ 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Webzine.Repository/DbArtisteRepository.cs b/Webzine.Repository/DbArtisteRepository.cs index fa6ff18..c27c1d7 100644 --- a/Webzine.Repository/DbArtisteRepository.cs +++ b/Webzine.Repository/DbArtisteRepository.cs @@ -83,8 +83,8 @@ namespace Webzine.Repository try { Artiste artiste = this.context.Artistes - .Include(a => a.Titres) - .First(a => a.IdArtiste == id); + .Include(a => a.Titres) + .FirstOrDefault(a => a.IdArtiste == id); return artiste; } catch (Exception ex) diff --git a/Webzine.Repository/DbTitreRepository.cs b/Webzine.Repository/DbTitreRepository.cs index 6dcbe21..ab362b9 100644 --- a/Webzine.Repository/DbTitreRepository.cs +++ b/Webzine.Repository/DbTitreRepository.cs @@ -262,7 +262,6 @@ public class DbTitreRepository : ITitreRepository try { this.logger.LogDebug("Recherche du titre avec l'ID: {IdTitre}", idTitre); - this.logger.LogDebug("Préparation de la requête avec les inclusions Artiste, Styles et Commentaires"); var titre = this.context.Titres .Include(t => t.Artiste) @@ -270,7 +269,6 @@ public class DbTitreRepository : ITitreRepository .Include(t => t.Commentaires) .FirstOrDefault(t => t.IdTitre == idTitre); - this.logger.LogDebug("Titre trouvé: {Libelle}", titre.Libelle); return titre; } catch (InvalidOperationException ex) diff --git a/Webzine.WebApplication/Areas/Administration/Controllers/ArtisteController.cs b/Webzine.WebApplication/Areas/Administration/Controllers/ArtisteController.cs index fcaf920..7df257a 100644 --- a/Webzine.WebApplication/Areas/Administration/Controllers/ArtisteController.cs +++ b/Webzine.WebApplication/Areas/Administration/Controllers/ArtisteController.cs @@ -87,6 +87,12 @@ public class ArtisteController : Controller public IActionResult Delete(int id) { var artiste = this.artisteRepository.Find(id); + + if (artiste == null) + { + return this.RedirectToAction("Index"); + } + var model = new AdminArtisteForm { Id = id, diff --git a/Webzine.WebApplication/Areas/Administration/Controllers/CommentaireController.cs b/Webzine.WebApplication/Areas/Administration/Controllers/CommentaireController.cs index c60e9bd..b954e14 100644 --- a/Webzine.WebApplication/Areas/Administration/Controllers/CommentaireController.cs +++ b/Webzine.WebApplication/Areas/Administration/Controllers/CommentaireController.cs @@ -53,6 +53,11 @@ namespace Webzine.WebApplication.Areas.Administration.Controllers { var commentaire = this.commentaireRepository.Find(id); + if (commentaire == null) + { + return this.RedirectToAction("Index"); + } + var model = new CommentaireDeleteViewModel { IdCommentaire = commentaire.IdCommentaire, diff --git a/Webzine.WebApplication/Areas/Administration/Controllers/TitreController.cs b/Webzine.WebApplication/Areas/Administration/Controllers/TitreController.cs index f703fec..cab47aa 100644 --- a/Webzine.WebApplication/Areas/Administration/Controllers/TitreController.cs +++ b/Webzine.WebApplication/Areas/Administration/Controllers/TitreController.cs @@ -130,6 +130,11 @@ public class TitreController : Controller { var titre = this.titreRepository.Find(id); + if (titre == null) + { + return this.RedirectToAction("Index"); + } + var model = new AdminTitreDelete { Id = titre.IdTitre, From d3097545ad345d02aaa6f048693cce778621e047 Mon Sep 17 00:00:00 2001 From: Loic Masi Date: Tue, 31 Mar 2026 19:45:50 +0200 Subject: [PATCH 14/22] #167 : Ajout des CRUD sur Style. --- .../Controllers/StyleController.cs | 234 +++++++++++------- .../ViewModels/Styles/StyleCreateViewModel.cs | 3 + .../ViewModels/Styles/StyleEditViewModel.cs | 7 +- 3 files changed, 158 insertions(+), 86 deletions(-) diff --git a/Webzine.WebApplication/Areas/Administration/Controllers/StyleController.cs b/Webzine.WebApplication/Areas/Administration/Controllers/StyleController.cs index e6741f9..aabde2b 100644 --- a/Webzine.WebApplication/Areas/Administration/Controllers/StyleController.cs +++ b/Webzine.WebApplication/Areas/Administration/Controllers/StyleController.cs @@ -1,109 +1,175 @@ -namespace Webzine.WebApplication.Areas.Administration.Controllers -{ - using Microsoft.AspNetCore.Mvc; +namespace Webzine.WebApplication.Areas.Administration.Controllers; - using Webzine.Repository.Contracts; - using Webzine.WebApplication.Areas.Administration.ViewModels.Style; +using Microsoft.AspNetCore.Mvc; + +using Webzine.Entity; +using Webzine.Repository.Contracts; +using Webzine.WebApplication.Areas.Administration.ViewModels.Style; + +/// +/// Controleur pour la gestion des styles dans l'administration du webzine. +/// +[Area("Administration")] +public class StyleController : Controller +{ + private readonly ILogger logger; + private readonly IStyleRepository styleRepository; /// - /// Contrôleur pour la gestion des styles dans l'administration du webzine. + /// Initializes a new instance of the class. /// - [Area("Administration")] - public class StyleController : Controller + /// Service de journalisation injecte. + /// Repository des styles injecte. + public StyleController( + ILogger logger, + IStyleRepository styleRepository) { - private readonly ILogger logger; - private readonly IStyleRepository styleRepository; + this.logger = logger; + this.styleRepository = styleRepository; - /// - /// Initializes a new instance of the class. - /// Initialise une nouvelle instance de la classe . - /// - /// Service de journalisation injecté. - /// Repository des styles injecté. - public StyleController( - ILogger logger, - IStyleRepository styleRepository) + this.logger.LogInformation("Initialisation du controleur StyleController."); + } + + /// + /// Affiche la liste des styles dans la vue Index. + /// + /// La vue Index avec la liste des styles. + public IActionResult Index() + { + IEnumerable