#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

@@ -28,7 +28,7 @@ public class LocalTitreRepository : ITitreRepository
/// <inheritdoc/>
public void Add(Titre titre)
{
throw new NotSupportedException("Mode local");
this.dataStore.Titres.Add(titre);
}
/// <inheritdoc/>
@@ -41,7 +41,7 @@ public class LocalTitreRepository : ITitreRepository
/// <inheritdoc/>
public void Delete(Titre titre)
{
throw new NotSupportedException("Mode Local");
this.dataStore.Titres.Remove(titre);
}
/// <inheritdoc/>
@@ -115,6 +115,18 @@ public class LocalTitreRepository : ITitreRepository
/// <inheritdoc/>
public void Update(Titre titre)
{
throw new NotSupportedException("Mode local");
var stored = this.dataStore.Titres.FirstOrDefault(t => t.IdTitre == titre.IdTitre);
if (stored == null)
{
this.logger.LogWarning("Titre avec l'ID {Id} non trouvé pour mise à jour.", titre.IdTitre);
return;
}
stored.Libelle = titre.Libelle;
stored.DateCreation = titre.DateCreation;
stored.NbLectures = titre.NbLectures;
stored.NbLikes = titre.NbLikes;
stored.IdArtiste = titre.IdArtiste;
stored.Styles = titre.Styles;
}
}