#146 Les méthodes Find(id) des repository utilisent SingleOrDefault. Les méthodes find du repository sont utilisées dans les méthodes update au lieu de refaire une requête. Paginate est remplacé par Find[Model] pour correspondre au cahier des charges.

This commit is contained in:
josephine.vetu
2026-04-02 14:41:01 +02:00
parent ae80c3e14e
commit 198b716074
9 changed files with 73 additions and 65 deletions

View File

@@ -104,10 +104,9 @@ public class DbTitreRepository : ITitreRepository
.OrderBy(t => t.Libelle)
.Skip(offset)
.Take(limit)
.AsNoTracking()
.ToList();
.AsNoTracking();
this.logger.LogDebug("{Count} titres trouvés", titres.Count);
this.logger.LogDebug("La liste de titres a été récupérée.");
return titres;
}
catch (Exception ex)
@@ -182,7 +181,7 @@ public class DbTitreRepository : ITitreRepository
{
this.logger.LogInformation("Mise à jour du titre avec l'ID: {IdTitre}", titre.IdTitre);
var existingTitre = this.context.Titres.Find(titre.IdTitre);
Titre existingTitre = this.Find(titre.IdTitre);
if (existingTitre != null)
{
this.context.Entry(existingTitre).CurrentValues.SetValues(titre);
@@ -228,10 +227,9 @@ public class DbTitreRepository : ITitreRepository
.Include(t => t.Styles)
.Where(t => t.Libelle.ToLower().Contains(mot.ToLower()))
.OrderBy(t => t.Libelle)
.AsNoTracking()
.ToList();
.AsNoTracking();
this.logger.LogDebug("{Count} titres trouvés correspondant à '{Mot}'", titres.Count, mot);
this.logger.LogDebug("La liste de titres a été récupérée.");
return titres;
}
catch (Exception ex)
@@ -278,10 +276,9 @@ public class DbTitreRepository : ITitreRepository
.Include(t => t.Styles)
.Include(t => t.Commentaires)
.OrderBy(t => t.Libelle)
.AsNoTracking()
.ToList();
.AsNoTracking();
this.logger.LogDebug("{Count} titres récupérés", titres.Count);
this.logger.LogDebug("La liste de titres a été récupérée avec FindAll.");
return titres;
}
catch (Exception ex)
@@ -303,10 +300,9 @@ public class DbTitreRepository : ITitreRepository
.Include(t => t.Styles)
.Where(t => t.Styles.Any(s => s.Libelle.ToLower() == libelle.ToLower()))
.OrderBy(t => t.Libelle)
.AsNoTracking()
.ToList();
.AsNoTracking();
this.logger.LogDebug("{Count} titres trouvés pour le style '{Libelle}'", titres.Count, libelle);
this.logger.LogDebug("La liste de titres a été récupérée pour le style '{Libelle}'", libelle);
return titres;
}
catch (Exception ex)