feat: Mise en œuvre ILocalEntityRepository et mise à jour LocalEntityRepository pour ensemencer les données
This commit is contained in:
@@ -1,22 +1,45 @@
|
||||
namespace Webzine.Repository;
|
||||
using Webzine.Repository.Contracts;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Webzine.Repository;
|
||||
|
||||
using Entity;
|
||||
using Entity.Fixtures;
|
||||
|
||||
public class LocalEntityRepository
|
||||
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()
|
||||
{
|
||||
var seedData = new DataFactory();
|
||||
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);
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Faker.Net" Version="2.0.163" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.3" />
|
||||
<PackageReference Include="NLog" Version="6.1.1" />
|
||||
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
@@ -23,6 +24,13 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Webzine.Entity\Webzine.Entity.csproj" />
|
||||
<ProjectReference Include="..\Webzine.Repository.Contracts\Webzine.Repository.Contracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.Testing.Platform">
|
||||
<HintPath>..\..\..\..\..\..\..\.nuget\packages\microsoft.testing.platform\2.0.1\lib\net9.0\Microsoft.Testing.Platform.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user