#154 : Déplacement de la recherche des artistes dans les RepositoryArtiste.
This commit is contained in:
@@ -44,5 +44,12 @@ namespace Webzine.Repository.Contracts
|
||||
/// </summary>
|
||||
/// <param name="artiste">L'artiste à mettre à jour.</param>
|
||||
void Update(Artiste artiste);
|
||||
|
||||
/// <summary>
|
||||
/// Récupérer une liste d'artiste à partir d'une recherche.
|
||||
/// </summary>
|
||||
/// <param name="nom">Nom de l'artiste.</param>
|
||||
/// <returns>IEnumarble<Artiste> qui contient la chaine de caractere.</returns>
|
||||
IEnumerable<Artiste> Search(string nom);
|
||||
}
|
||||
}
|
||||
@@ -4,8 +4,6 @@
|
||||
|
||||
namespace Webzine.Repository
|
||||
{
|
||||
using System.Data.Common;
|
||||
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
@@ -156,5 +154,23 @@ namespace Webzine.Repository
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public IEnumerable<Artiste> Search(string mot)
|
||||
{
|
||||
try
|
||||
{
|
||||
var artiste = this.context.Artistes
|
||||
.Where(a => a.Nom.ToLower().Contains(mot.ToLower()))
|
||||
.Include(t => t.Titres)
|
||||
.AsNoTracking()
|
||||
.ToList();
|
||||
return artiste;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Erreur lors de la recherche d'artiste {error}", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -85,5 +85,13 @@ namespace Webzine.Repository
|
||||
{
|
||||
throw new NotSupportedException("Mode Local");
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public IEnumerable<Artiste> Search(string mot)
|
||||
{
|
||||
return this.dataStore.Artistes
|
||||
.Where(a => a.Nom.ToLower().Contains(mot.ToLower()))
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,12 +29,9 @@ namespace Webzine.WebApplication.Controllers
|
||||
{
|
||||
this.logger.LogInformation("Recherche artistes/titres pour le mot : {Mot}.", mot);
|
||||
|
||||
var titres = this.titreRepository.Search(mot).ToList();
|
||||
var titres = this.titreRepository.Search(mot);
|
||||
|
||||
var artistes = this.artisteRepository
|
||||
.FindAll()
|
||||
.Where(a => a.Nom.ToLower().Contains(mot.ToLower()))
|
||||
.ToList();
|
||||
var artistes = this.artisteRepository.Search(mot);
|
||||
|
||||
var vm = new RechercheIndexViewModel
|
||||
{
|
||||
|
||||
@@ -14,11 +14,11 @@ namespace Webzine.WebApplication.ViewModels.Recherche
|
||||
/// <summary>
|
||||
/// Artistes trouves.
|
||||
/// </summary>
|
||||
public List<Artiste> Artistes { get; set; } = new ();
|
||||
public IEnumerable<Artiste> Artistes { get; set; } = new List<Artiste>();
|
||||
|
||||
/// <summary>
|
||||
/// Titres trouves.
|
||||
/// </summary>
|
||||
public List<Titre> Titres { get; set; } = new ();
|
||||
public IEnumerable<Titre> Titres { get; set; } = new List<Titre>();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user