refactor: optimiser la logique de génération de commentaires dans SeedDataLocal et les fichiers associés

This commit is contained in:
mirage
2026-03-27 15:07:40 +01:00
parent 30631676f8
commit 1eb8e93bfc
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();
}
}