#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

@@ -47,7 +47,7 @@ namespace Webzine.Repository
/// <inheritdoc/>
public Commentaire Find(int idCommentaire)
{
return this.dataStore.Commentaires.FirstOrDefault(c => c.IdCommentaire == idCommentaire);
return this.dataStore.Commentaires.SingleOrDefault(c => c.IdCommentaire == idCommentaire);
}
/// <inheritdoc/>
@@ -59,13 +59,12 @@ namespace Webzine.Repository
}
/// <inheritdoc/>
public IEnumerable<Commentaire> Paginate(int offset, int limit)
public IEnumerable<Commentaire> FindCommentaires(int offset, int limit)
{
return this.dataStore.Commentaires
.OrderByDescending(c => c.DateCreation)
.Skip(offset)
.Take(limit)
.ToList();
.Take(limit);
}
}
}