45 lines
1.4 KiB
C#
45 lines
1.4 KiB
C#
using Webzine.Repository.Contracts;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace Webzine.Repository;
|
|
|
|
using Entity;
|
|
using Entity.Fixtures;
|
|
|
|
public class LocalEntityRepository : ILocalEntityRepository
|
|
{
|
|
private readonly ILogger<LocalEntityRepository> _logger;
|
|
public LocalEntityRepository(ILogger<LocalEntityRepository> logger)
|
|
{
|
|
this._logger = logger;
|
|
this._logger.LogDebug(1, "NLog injected into LocalEntityRepository");
|
|
}
|
|
|
|
public List<Artiste> Artistes { get; set; }
|
|
public List<Style> Styles { get; set; }
|
|
public List<Titre> Titres { get; set; }
|
|
public List<Commentaire> Commentaires { get; set; }
|
|
|
|
/// <summary>
|
|
/// Permet de remplir les listes d'entités avec des données de test.
|
|
/// </summary>
|
|
public void Seed()
|
|
{
|
|
this._logger.LogInformation("Seed was called");
|
|
try
|
|
{
|
|
var seedData = new DataFactory();
|
|
|
|
Artistes = seedData.GenerateArtists(10);
|
|
Styles = seedData.GenerateStyles(8);
|
|
Titres = seedData.GenerateTitres(seedData.RealMusicData.Count, Artistes);
|
|
Commentaires = seedData.GenerateCommentaires(30, Titres);
|
|
this._logger.LogInformation("Seed was completed");
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
this._logger.LogError(e, "An error occurred while seeding the data");
|
|
throw;
|
|
}
|
|
}
|
|
} |