From 5c7af80f1bbab324b90d598998f0516660dc6995 Mon Sep 17 00:00:00 2001 From: Loic Masi Date: Thu, 26 Mar 2026 15:02:34 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20du=20seeder=20de=20la=20base=20de=20don?= =?UTF-8?q?n=C3=A9es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Webzine.Entity/Fixtures/SeedDataLocal.cs | 14 ++++- Webzine.Repository/DbEntityRepository.cs | 63 +++++++++++++++++++ Webzine.WebApplication/Program.cs | 23 ++++--- .../Views/Shared/_Layout.cshtml | 2 +- 4 files changed, 88 insertions(+), 14 deletions(-) create mode 100644 Webzine.Repository/DbEntityRepository.cs diff --git a/Webzine.Entity/Fixtures/SeedDataLocal.cs b/Webzine.Entity/Fixtures/SeedDataLocal.cs index bd2479e..544b730 100644 --- a/Webzine.Entity/Fixtures/SeedDataLocal.cs +++ b/Webzine.Entity/Fixtures/SeedDataLocal.cs @@ -1,6 +1,14 @@ -namespace Webzine.Entity.Fixtures; +// +// Copyright (c) PlaceholderCompany. All rights reserved. +// -public class SeedDataLocal -{ +namespace Webzine.Entity.Fixtures +{ + public class SeedDataLocal + { + public SeedDataLocal() + { + } + } } \ No newline at end of file diff --git a/Webzine.Repository/DbEntityRepository.cs b/Webzine.Repository/DbEntityRepository.cs new file mode 100644 index 0000000..3abfeb5 --- /dev/null +++ b/Webzine.Repository/DbEntityRepository.cs @@ -0,0 +1,63 @@ +// +// Copyright (c) PlaceholderCompany. All rights reserved. +// + +namespace Webzine.Repository +{ + using Webzine.EntitiesContext; + using Webzine.Entity; + using Webzine.Entity.Fixtures; + using Webzine.Repository.Fake; + + public class DbEntityRepository + { + private readonly WebzineDbContext context; + + public DbEntityRepository(WebzineDbContext context) + { + this.context = context; + } + + public void SeedBaseDeDonnees( + int nbArtistes = 100, + int nbTitres = 500, + int minStyles = 15, + int maxStyles = 20, + int minCommentairesParTitre = 0, + int maxCommentairesParTitre = 5) + { + if (this.context.Artistes.Any() || + this.context.Titres.Any() || + this.context.Styles.Any() || + this.context.Commentaires.Any()) + { + return; + } + + List artistes = ArtisteFactory.CreerListeArtiste(nbArtistes); + List