namespace Webzine.WebApplication.Extensions; public static class RouteConfiguration { /// /// Configure les routes de l'application. /// public static void MapCustomRoutes(this IEndpointRouteBuilder endpoints) { // ----------- TITRE ----------- endpoints.MapControllerRoute( name: "TitreStyle", pattern: "titres/style/{style}", defaults: new { controller = "Titre", action = "Style" }); endpoints.MapControllerRoute( name: "TitreIndex", pattern: "titre/{id}", defaults: new { controller = "Titre", action = "Index" }); endpoints.MapControllerRoute( name: "ArtisteIndex", pattern: "artiste/{nom}", defaults: new { controller = "Artiste", action = "Index" }); endpoints.MapControllerRoute( name: "TitreLike", pattern: "titre/{id}/like", defaults: new { controller = "Titre", action = "Like" }); endpoints.MapControllerRoute( name: "TitreComment", pattern: "titre/{id}/comment", defaults: new { controller = "Titre", action = "Comment" }); // ----------- ADMIN ----------- var adminRoutes = new Dictionary { { "artistes", "Artiste" }, { "commentaires", "Commentaire" }, { "styles", "Style" }, { "titres", "Titre" }, }; foreach (var route in adminRoutes) { endpoints.MapControllerRoute( name: $"Admin{route.Value}Index", pattern: $"administration/{route.Key}", defaults: new { area = "Administration", controller = route.Value, action = "Index" }); } // --- AUTRES ROUTES --- endpoints.MapControllerRoute( name: "areas", pattern: "{area:exists}/{controller=Home}/{action=Index}/{id?}"); endpoints.MapControllerRoute( name: "default", pattern: "{controller=Accueil}/{action=Index}/{id?}"); } }