46 lines
1.4 KiB
C#
46 lines
1.4 KiB
C#
// <copyright file="RechercheController.cs" company="PlaceholderCompany">
|
|
// Copyright (c) PlaceholderCompany. All rights reserved.
|
|
// </copyright>
|
|
|
|
namespace Webzine.WebApplication.Controllers
|
|
{
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
using Webzine.Repository.Contracts;
|
|
using Webzine.WebApplication.ViewModels.Recherche;
|
|
|
|
public class RechercheController : Controller
|
|
{
|
|
private readonly ILogger<RechercheController> logger;
|
|
private readonly ITitreRepository titreRepository;
|
|
private readonly IArtisteRepository artisteRepository;
|
|
|
|
public RechercheController(
|
|
ILogger<RechercheController> logger,
|
|
ITitreRepository titreRepository,
|
|
IArtisteRepository artisteRepository)
|
|
{
|
|
this.logger = logger;
|
|
this.titreRepository = titreRepository;
|
|
this.artisteRepository = artisteRepository;
|
|
}
|
|
|
|
public IActionResult Index(string mot)
|
|
{
|
|
this.logger.LogInformation("Recherche artistes/titres pour le mot : {Mot}.", mot);
|
|
|
|
var titres = this.titreRepository.Search(mot);
|
|
|
|
var artistes = this.artisteRepository.Search(mot);
|
|
|
|
var vm = new RechercheIndexViewModel
|
|
{
|
|
Mot = mot,
|
|
Artistes = artistes,
|
|
Titres = titres,
|
|
};
|
|
|
|
return this.View(vm);
|
|
}
|
|
}
|
|
} |