Rebase de j3/feat/pagination dans j3/seed_spotify.
This commit is contained in:
@@ -207,5 +207,26 @@ namespace Webzine.Repository
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public IEnumerable<Artiste> FindArtistes(int offset, int limit)
|
||||
{
|
||||
try
|
||||
{
|
||||
var artistes = this.context.Artistes
|
||||
.AsNoTracking()
|
||||
.OrderBy(a => a.Nom)
|
||||
.Include(t => t.Titres)
|
||||
.Skip(offset)
|
||||
.Take(limit);
|
||||
this.logger.LogDebug("Page {PageNumber} d'artistes récupérée avec {PageSize} artistes par page.", offset, limit);
|
||||
return artistes;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.logger.LogError(ex, "Erreur lors de la pagination des artistes. Page: {PageNumber}, Taille: {PageSize}", offset, limit);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -114,4 +114,19 @@ public class DbCommentaireRepository : ICommentaireRepository
|
||||
throw new Exception("Une erreur est survenue lors de la pagination des commentaires.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public int Count()
|
||||
{
|
||||
try
|
||||
{
|
||||
this.logger.LogDebug("Comptage du nombre total de commentaires");
|
||||
return Enumerable.Count(this.context.Commentaires);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.logger.LogError(ex, "Erreur lors du comptage des commentaires");
|
||||
throw new Exception("Une erreur est survenue lors du comptage des commentaires.", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -182,4 +182,27 @@ public class DbStyleRepository : IStyleRepository
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public IEnumerable<Style> FindStyles(int offset, int limit)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.logger.LogDebug("Récupération paginée des styles (offset: {Offset}, limit: {Limit})", offset, limit);
|
||||
|
||||
var styles = this.context.Styles
|
||||
.AsNoTracking()
|
||||
.OrderBy(s => s.Libelle)
|
||||
.Skip(offset)
|
||||
.Take(limit);
|
||||
|
||||
this.logger.LogDebug("La liste paginée de styles a été récupérée.");
|
||||
return styles;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.logger.LogError(ex, "Erreur lors de la récupération paginée des styles (offset: {Offset}, limit: {Limit})", offset, limit);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -103,14 +103,14 @@ public class DbTitreRepository : ITitreRepository
|
||||
this.logger.LogDebug("Préparation de la requête avec les inclusions Artiste et Styles");
|
||||
|
||||
var titres = this.context.Titres
|
||||
.OrderByDescending(t => t.DateCreation)
|
||||
.ThenBy(t => t.Libelle)
|
||||
.Include(t => t.Artiste)
|
||||
.Include(t => t.Styles)
|
||||
.OrderBy(t => t.Libelle)
|
||||
.Skip(offset)
|
||||
.Take(limit)
|
||||
.ToList();
|
||||
.AsNoTracking();
|
||||
|
||||
this.logger.LogDebug("{Count} titres trouvés", titres.Count);
|
||||
return titres;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -233,17 +233,14 @@ public class DbTitreRepository : ITitreRepository
|
||||
try
|
||||
{
|
||||
this.logger.LogInformation("Recherche des titres avec le mot-clé: {Mot}", mot);
|
||||
this.logger.LogDebug("Préparation de la requête de recherche avec les inclusions");
|
||||
|
||||
var titres = this.context.Titres
|
||||
.Include(t => t.Artiste)
|
||||
.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);
|
||||
return titres;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -264,7 +261,7 @@ public class DbTitreRepository : ITitreRepository
|
||||
.Include(t => t.Artiste)
|
||||
.Include(t => t.Styles)
|
||||
.Include(t => t.Commentaires)
|
||||
.FirstOrDefault(t => t.IdTitre == idTitre);
|
||||
.SingleOrDefault(t => t.IdTitre == idTitre);
|
||||
|
||||
return titre;
|
||||
}
|
||||
@@ -293,9 +290,9 @@ public class DbTitreRepository : ITitreRepository
|
||||
.Include(t => t.Styles)
|
||||
.Include(t => t.Commentaires)
|
||||
.OrderBy(t => t.Libelle)
|
||||
.ToList();
|
||||
.AsNoTracking();
|
||||
|
||||
this.logger.LogDebug("{Count} titres récupérés", titres.Count);
|
||||
this.logger.LogDebug("{Count} titres récupérés", titres.Count());
|
||||
return titres;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -318,9 +315,9 @@ public class DbTitreRepository : ITitreRepository
|
||||
.Include(t => t.Styles)
|
||||
.Where(t => t.Styles.Any(s => s.Libelle.ToLower() == libelle.ToLower()))
|
||||
.OrderBy(t => t.Libelle)
|
||||
.ToList();
|
||||
.AsNoTracking();
|
||||
|
||||
this.logger.LogDebug("{Count} titres trouvés pour le style '{Libelle}'", titres.Count, libelle);
|
||||
this.logger.LogDebug("{Count} titres trouvés pour le style '{Libelle}'", titres.Count(), libelle);
|
||||
return titres;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -106,5 +106,15 @@ namespace Webzine.Repository
|
||||
{
|
||||
return this.dataStore.Artistes.Count(predicate);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public IEnumerable<Artiste> FindArtistes(int offset, int limit)
|
||||
{
|
||||
return this.dataStore.Artistes
|
||||
.OrderBy(a => a.Nom)
|
||||
.Skip(offset)
|
||||
.Take(limit)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,5 +66,11 @@ namespace Webzine.Repository
|
||||
.Skip(offset)
|
||||
.Take(limit);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public int Count()
|
||||
{
|
||||
return this.dataStore.Commentaires.Count;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -71,4 +71,14 @@ public class LocalStyleRepository : IStyleRepository
|
||||
{
|
||||
return this.dataStore.Styles.Count;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public IEnumerable<Style> FindStyles(int offset, int limit)
|
||||
{
|
||||
return this.dataStore.Styles
|
||||
.OrderBy(s => s.Libelle)
|
||||
.Skip(offset)
|
||||
.Take(limit)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
@@ -49,6 +49,7 @@ public class LocalTitreRepository : ITitreRepository
|
||||
{
|
||||
return this.dataStore.Titres
|
||||
.OrderByDescending(t => t.DateCreation)
|
||||
.ThenBy(t => t.Libelle)
|
||||
.Skip(offset)
|
||||
.Take(limit);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user