Modification de la page d'accueil.

Ajout des paramètres dans le fichier appsettings pour choisir le nombre de chronique ou de titres les plus likes à afficher.
Ajout des relations qui permettent de fakes les données affichés sur la page d'accueil.
This commit is contained in:
Loic Masi
2026-03-05 13:54:09 +01:00
parent 3a62a7e24a
commit 94b84bdfb1
8 changed files with 170 additions and 201 deletions

View File

@@ -0,0 +1,63 @@
using System;
using System.Collections.Generic;
using Faker;
using Webzine.Entity;
namespace Webzine.Repository.Fake
{
public static class FakeDataFactory
{
//https://cdn-images.dzcdn.net/images/cover/311bba0fc112d15f72c8b5a65f0456c1/1900x1900-000000-80-0-0.jpg",
public static List<Artiste> GetArtistes(int count = 10)
{
var artistes = new List<Artiste>();
for (int i = 1; i <= count; i++)
{
artistes.Add(new Artiste
{
IdArtiste = i,
Nom = Name.FullName(),
Biographie = Lorem.Paragraph(),
Titres = new List<Titre>()
});
}
return artistes;
}
public static List<Titre> GetTitres(int count = 40)
{
var artistes = GetArtistes();
var titres = new List<Titre>();
for (int i = 1; i <= count; i++)
{
var artiste = artistes[RandomNumber.Next(0, artistes.Count - 1)];
var titre = new Titre
{
IdTitre = i,
IdArtiste = artiste.IdArtiste,
Artiste = artiste,
Libelle = Lorem.Sentence(3),
Chronique = Lorem.Paragraph(),
DateCreation = DateTime.Now.AddDays(-RandomNumber.Next(1, 100)),
DateSortie = DateTime.Now.AddYears(-RandomNumber.Next(1, 20)),
Duree = RandomNumber.Next(120, 420),
UrlJaquette = "https://picsum.photos/300",
UrlEcoute = Internet.Url(),
NbLectures = RandomNumber.Next(0, 500),
NbLikes = RandomNumber.Next(0, 200),
Album = Lorem.Sentence(2),
Commentaires = new List<Commentaire>()
};
titres.Add(titre);
artiste.Titres.Add(titre);
}
return titres;
}
}
}

View File

@@ -21,4 +21,8 @@
</Content>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Webzine.Entity\Webzine.Entity.csproj" />
</ItemGroup>
</Project>