Merge pull request 'refactor: optimiser la logique de génération de commentaires dans SeedDataLocal et les fichiers associés' (#135) from j2/fix/dev into dev

Reviewed-on: https://10.4.0.131/gitea/DI1-P4-E1/Webzine/pulls/135
Reviewed-by: Loic Masi <loic.masi@diiage.org>
This commit is contained in:
Loic Masi
2026-03-27 15:33:00 +01:00
3 changed files with 17 additions and 11 deletions

View File

@@ -46,11 +46,17 @@ namespace Webzine.Repository
this.context.SaveChanges();
List<string> albums = SeedDataLocal.GenererListeAlbums(3);
List<Commentaire> commentaires = new List<Commentaire>();
List<Titre> titres = SeedDataLocal.GenererListeTitre(nbTitres, artistes, styles, albums, commentaires);
this.context.Titres.AddRange(titres);
this.context.SaveChanges();
List<Titre> titres = SeedDataLocal.GenererListeTitre(nbTitres, artistes, styles, albums);
int commentaireIdStart = 1;
foreach (var titre in titres)
{
var commentairesDuTitre = SeedDataLocal.GenererListeCommentaire(titre, 0, 5, commentaireIdStart);
titre.Commentaires.AddRange(commentairesDuTitre);
commentaireIdStart += commentairesDuTitre.Count;
}
this.context.Titres.AddRange(titres);
this.context.SaveChanges();
}
}