Files
webzine/Webzine.Repository/LocalStyleRepository.cs
2026-03-28 10:09:18 +01:00

58 lines
1.7 KiB
C#

using Microsoft.Extensions.Logging;
using Webzine.Entity;
using Webzine.Repository.Contracts;
namespace Webzine.Repository;
/// <summary>
/// Classe qui implémente le repository pour les styles en utilisant une liste locale comme source de données.
/// </summary>
public class LocalStyleRepository : IStyleRepository
{
private readonly ILogger<LocalStyleRepository> logger;
// private readonly List<Style> styles;
private readonly InMemoryDataStore dataStore;
/// <summary>
/// Initializes a new instance of the <see cref="LocalStyleRepository"/> class.
/// </summary>
/// <param name="logger">Le service de journalisation injecté pour suivre les opérations du repository.</param>
/// <param name="styles">La liste de styles à utiliser comme source de données pour le repository.</param>
public LocalStyleRepository(ILogger<LocalStyleRepository> logger, InMemoryDataStore dataStore)
{
this.logger = logger;
this.dataStore = dataStore;
this.logger.LogDebug(1, "NLog injecté dans LocalStyleRepository");
}
/// <inheritdoc/>
public void Add(Style style)
{
throw new NotSupportedException("Mode local");
}
/// <inheritdoc/>
public void Delete(Style style)
{
throw new NotSupportedException("Mode local");
}
/// <inheritdoc/>
public Style Find(int id)
{
return this.dataStore.Styles.Find(s => s.IdStyle == id);
}
/// <inheritdoc/>
public IEnumerable<Style> FindAll()
{
return this.dataStore.Styles.ToList();
}
/// <inheritdoc/>
public void Update(Style style)
{
throw new NotSupportedException("Mode local");
}
}