78 lines
2.7 KiB
C#
78 lines
2.7 KiB
C#
// <copyright file="LocalArtisteRepository.cs" company="PlaceholderCompany">
|
|
// Copyright (c) PlaceholderCompany. All rights reserved.
|
|
// </copyright>
|
|
|
|
namespace Webzine.Repository
|
|
{
|
|
using Microsoft.Extensions.Logging;
|
|
using Webzine.Entity;
|
|
using Webzine.Repository.Contracts;
|
|
|
|
/// <summary>
|
|
/// Initialise une classe <see cref="LocalArtisteRepository"/> qui implémente l'interface <see cref="IArtisteRepository"/> pour gérer les opérations de base de données liées aux artistes.
|
|
/// Utilise <see cref="IArtisteRepository"/> en injection de dépendances.
|
|
/// </summary>
|
|
public class LocalArtisteRepository : IArtisteRepository
|
|
{
|
|
private readonly ILogger<LocalArtisteRepository> logger;
|
|
//private readonly List<Artiste> artistes;
|
|
private readonly InMemoryDataStore dataStore;
|
|
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="LocalArtisteRepository"/> class.
|
|
/// Est liéee à une liste d'artistes en local et utilise un logger pour enregistrer les opérations effectuées sur les artistes.
|
|
/// </summary>
|
|
/// <param name="artistes">La liste des artistes à initialiser. Ne peut pas être null.</param>
|
|
/// <param name="logger">Le logger à utiliser pour enregistrer les messages de journalisation. Ne peut pas être null.</param>
|
|
public LocalArtisteRepository(InMemoryDataStore dataStore, ILogger<LocalArtisteRepository> logger)
|
|
{
|
|
this.logger = logger;
|
|
//this.artistes = artistes;
|
|
this.dataStore = dataStore;
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
public void Add(Artiste artiste)
|
|
{
|
|
throw new NotSupportedException("Mode Local");
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
public void Delete(Artiste artiste)
|
|
{
|
|
throw new NotSupportedException("Mode Local");
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
public Artiste Find(int id)
|
|
{
|
|
var artiste = this.dataStore.Artistes.First(a => a.IdArtiste == id);
|
|
if (artiste == null)
|
|
{
|
|
return new Artiste();
|
|
}
|
|
|
|
return artiste;
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
public Artiste FindByName(string nom)
|
|
{
|
|
return this.dataStore.Artistes.First(a => a.Nom == nom);
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
/// La liste retournée est une copie de la liste interne, donc elle ne peut être nulle.
|
|
public IEnumerable<Artiste> FindAll()
|
|
{
|
|
return this.dataStore.Artistes;
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
public void Update(Artiste artiste)
|
|
{
|
|
throw new NotSupportedException("Mode Local");
|
|
}
|
|
}
|
|
} |