#184 Implémentation des méthodes des repo en local. Suprression des exceptions de non implementation.

This commit is contained in:
josephine.vetu
2026-04-01 16:48:18 +02:00
parent 286397cb9e
commit afc9f1bdb4
4 changed files with 42 additions and 17 deletions

View File

@@ -36,21 +36,19 @@ namespace Webzine.Repository
/// <inheritdoc/>
public void Add(Artiste artiste)
{
throw new NotSupportedException("Mode Local"); // TODO à implémenter
this.dataStore.Artistes.Add(artiste);
}
/// <inheritdoc/>
public void Delete(Artiste artiste)
{
throw new NotSupportedException("Mode Local");
this.dataStore.Artistes.Remove(artiste);
}
/// <inheritdoc/>
public Artiste Find(int id)
{
var artiste = this.dataStore.Artistes.SingleOrDefault(a => a.IdArtiste == id);
return artiste;
return this.dataStore.Artistes.SingleOrDefault(a => a.IdArtiste == id);
}
/// <inheritdoc/>
@@ -69,7 +67,6 @@ namespace Webzine.Repository
}
/// <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;
@@ -78,7 +75,16 @@ namespace Webzine.Repository
/// <inheritdoc/>
public void Update(Artiste artiste)
{
throw new NotSupportedException("Mode Local");
var stored = this.dataStore.Artistes.FirstOrDefault(a => a.IdArtiste == artiste.IdArtiste);
if (stored == null)
{
this.logger.LogWarning("L'artiste {Id} n'a pas été trouvé pour l'update.", artiste.IdArtiste);
return;
}
stored.Nom = artiste.Nom;
stored.Biographie = artiste.Biographie;
stored.Titres = artiste.Titres;
}
/// <inheritdoc/>