#87 Modification des factories pour pouvoir seeder la base de données et paramétrage de la fonction pour choisir le nombre d'éléments souhaité

This commit is contained in:
Loic Masi
2026-03-25 16:41:50 +01:00
parent 849f294418
commit 9801eb555f
8 changed files with 224 additions and 39 deletions

View File

@@ -0,0 +1,53 @@
// <copyright file="StyleFactory.cs" company="PlaceholderCompany">
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
namespace Webzine.Entity.Fixtures
{
using Webzine.Entity;
public class StyleFactory
{
/// <summary>
/// Générer une liste de style pour seeder la base
/// de données.
/// </summary>
/// <returns>Liste de style.</returns>
public static List<Style> CreerListeStyle(int minCount = 15, int maxCount = 20)
{
List<string> libelles = new List<string>
{
"Pop",
"Rock",
"Jazz",
"Blues",
"Hip-Hop",
"Rap",
"Electro",
"Techno",
"House",
"Metal",
"Funk",
"Soul",
"R&B",
"Classique",
"Reggae",
"Punk",
"Folk",
"Disco",
"Ambient",
"Indie",
};
Random random = new Random();
int count = random.Next(minCount, maxCount + 1);
return libelles
.Take(count)
.Select(libelle => new Style
{
Libelle = libelle,
})
.ToList();
}
}
}