refactor: optimiser la logique de génération de commentaires dans SeedDataLocal et les fichiers associés
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user