From 9801eb555f0b52d0f763669b7d6b23bf332e389a Mon Sep 17 00:00:00 2001 From: Loic Masi Date: Wed, 25 Mar 2026 16:41:50 +0100 Subject: [PATCH] =?UTF-8?q?#87=20Modification=20des=20factories=20pour=20p?= =?UTF-8?q?ouvoir=20seeder=20la=20base=20de=20donn=C3=A9es=20et=20param?= =?UTF-8?q?=C3=A9trage=20de=20la=20fonction=20pour=20choisir=20le=20nombre?= =?UTF-8?q?=20d'=C3=A9l=C3=A9ments=20souhait=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Webzine.Entity/Fixtures/ArtisteFactory.cs | 15 ++++ Webzine.Entity/Fixtures/CommentaireFactory.cs | 33 +++++++++ Webzine.Entity/Fixtures/StyleFactory.cs | 53 ++++++++++++++ Webzine.Entity/Fixtures/TitreFactory.cs | 51 +++++++++++++- Webzine.Repository/DbEntityRepository.cs | 69 ++++++++++++++++++- Webzine.Repository/Webzine.Repository.csproj | 1 + Webzine.WebApplication/Program.cs | 7 ++ .../Views/Shared/_Sidebar.cshtml | 34 --------- 8 files changed, 224 insertions(+), 39 deletions(-) create mode 100644 Webzine.Entity/Fixtures/CommentaireFactory.cs create mode 100644 Webzine.Entity/Fixtures/StyleFactory.cs diff --git a/Webzine.Entity/Fixtures/ArtisteFactory.cs b/Webzine.Entity/Fixtures/ArtisteFactory.cs index d8ecb26..44f297a 100644 --- a/Webzine.Entity/Fixtures/ArtisteFactory.cs +++ b/Webzine.Entity/Fixtures/ArtisteFactory.cs @@ -49,5 +49,20 @@ namespace Webzine.Entity.Fixtures return artisteFaker.Generate(); } + + /// + /// Permet de retourner une liste d'artiste pour seeder la base + /// de données. + /// + /// + /// Liste d'artiste. + public static List CreerListeArtiste(int nombre) + { + Faker faker = new Faker("fr") + .RuleFor(a => a.Nom, f => f.Person.FullName) + .RuleFor(a => a.Biographie, f => f.Lorem.Paragraph(2)); + + return faker.Generate(nombre); + } } } \ No newline at end of file diff --git a/Webzine.Entity/Fixtures/CommentaireFactory.cs b/Webzine.Entity/Fixtures/CommentaireFactory.cs new file mode 100644 index 0000000..790cfc2 --- /dev/null +++ b/Webzine.Entity/Fixtures/CommentaireFactory.cs @@ -0,0 +1,33 @@ +// +// Copyright (c) PlaceholderCompany. All rights reserved. +// + +using Bogus; + +namespace Webzine.Entity.Fixtures +{ + public class CommentaireFactory + { + /// + /// Seeder pour la base de données. + /// + /// Titre. + /// Min. + /// Max. + /// Liste de commentaire. + public static List CreerListeCommentaire(Titre titre, int min = 0, int max = 5) + { + Random random = new Random(); + int count = random.Next(min, max + 1); + + Faker faker = new Faker("fr") + .RuleFor(c => c.Auteur, f => f.Internet.UserName()) + .RuleFor(c => c.Contenu, f => f.Lorem.Sentences(2)) + .RuleFor(c => c.DateCreation, f => f.Date.Recent(60)) + .RuleFor(c => c.Titre, _ => titre) + .RuleFor(c => c.IdTitre, _ => titre.IdTitre); + + return faker.Generate(count); + } + } +} diff --git a/Webzine.Entity/Fixtures/StyleFactory.cs b/Webzine.Entity/Fixtures/StyleFactory.cs new file mode 100644 index 0000000..039f6f7 --- /dev/null +++ b/Webzine.Entity/Fixtures/StyleFactory.cs @@ -0,0 +1,53 @@ +// +// Copyright (c) PlaceholderCompany. All rights reserved. +// + +namespace Webzine.Entity.Fixtures +{ + using Webzine.Entity; + public class StyleFactory + { + /// + /// Générer une liste de style pour seeder la base + /// de données. + /// + /// Liste de style. + public static List