Merge branch 'dev' into J1/feat/AdminTitreIHM
# Conflicts: # Webzine.WebApplication/Areas/Administration/ViewModels/Accueil/AccueilIndexViewModel.cs # Webzine.WebApplication/Areas/Administration/ViewModels/ArtisteModel.cs # Webzine.WebApplication/Areas/Administration/Views/Commentaires/Index.cshtml # Webzine.WebApplication/Areas/Administration/Views/Shared/_Layout.cshtml # Webzine.WebApplication/Controllers/AccueilController.cs # Webzine.WebApplication/Webzine.WebApplication.csproj
This commit is contained in:
@@ -1,83 +1,44 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Webzine.Repository.Fake;
|
||||
using Webzine.WebApplication.ViewModels.Accueil;
|
||||
|
||||
namespace Webzine.WebApplication.Controllers
|
||||
{
|
||||
public class AccueilController : Controller
|
||||
{
|
||||
// Injection du logger via le constructeur
|
||||
private readonly ILogger<AccueilController> _logger;
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
public AccueilController(ILogger<AccueilController> logger, IConfiguration configuration)
|
||||
{
|
||||
_logger = logger;
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
// GET: AccueilController
|
||||
public ActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
_logger.LogInformation("Arrivée sur la page d'accueil");
|
||||
|
||||
// GET: AccueilController/Details/5
|
||||
public ActionResult Details(int id)
|
||||
{
|
||||
return View();
|
||||
}
|
||||
var derniereChronique = _configuration.GetValue<int>("Webzine:NombreDerniereChronique");
|
||||
var topTitres = _configuration.GetValue<int>("Webzine:NombreDeTopTitres");
|
||||
var titres = FakeDataFactory.GetTitres();
|
||||
|
||||
// GET: AccueilController/Create
|
||||
public ActionResult Create()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: AccueilController/Create
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public ActionResult Create(IFormCollection collection)
|
||||
{
|
||||
try
|
||||
var vm = new AccueilIndexViewModel
|
||||
{
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
catch
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
DerniersTitres = titres
|
||||
.OrderByDescending(t => t.DateCreation)
|
||||
.Take(derniereChronique)
|
||||
.ToList(),
|
||||
|
||||
// GET: AccueilController/Edit/5
|
||||
public ActionResult Edit(int id)
|
||||
{
|
||||
return View();
|
||||
}
|
||||
TopTitres = titres
|
||||
.OrderByDescending(t => t.NbLikes)
|
||||
.Take(topTitres)
|
||||
.ToList()
|
||||
};
|
||||
|
||||
// POST: AccueilController/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public ActionResult Edit(int id, IFormCollection collection)
|
||||
{
|
||||
try
|
||||
{
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
catch
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
|
||||
// GET: AccueilController/Delete/5
|
||||
public ActionResult Delete(int id)
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: AccueilController/Delete/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public ActionResult Delete(int id, IFormCollection collection)
|
||||
{
|
||||
try
|
||||
{
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
catch
|
||||
{
|
||||
return View();
|
||||
}
|
||||
return View(vm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
54
Webzine.WebApplication/Controllers/ArtisteController.cs
Normal file
54
Webzine.WebApplication/Controllers/ArtisteController.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Webzine.Entity.Fixtures;
|
||||
using Webzine.WebApplication.ViewModels;
|
||||
|
||||
namespace Webzine.WebApplication.Controllers
|
||||
{
|
||||
public class ArtisteController : Controller
|
||||
{
|
||||
// Injection du logger via le constructeur
|
||||
private readonly ILogger<ArtisteController> _logger;
|
||||
|
||||
public ArtisteController(ILogger<ArtisteController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Prend en paramètre le nom de l'artiste (ex: "fatal-bazooka"), utilise la factory pour trouver l'artiste correspondant, et affiche sa page dédiée.
|
||||
/// </summary>
|
||||
/// <param name="nom"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("/artiste/{nom}")]
|
||||
public IActionResult Index(string nom)
|
||||
{
|
||||
_logger.LogInformation("Tentative d'accès à l'artiste avec le nom : {NomArtiste}", nom);
|
||||
|
||||
if (string.IsNullOrEmpty(nom)) return RedirectToAction("Index", "Accueil");
|
||||
|
||||
// On transforme "fatal-bazooka" en "Fatal Bazooka" pour la factory
|
||||
string nomPropre = System.Globalization.CultureInfo.CurrentCulture.TextInfo
|
||||
.ToTitleCase(nom.Replace("-", " "));
|
||||
|
||||
// On appelle la factory pour obtenir l'artiste unique
|
||||
var artiste = ArtisteFactory.SeedArtisteByName(nomPropre);
|
||||
|
||||
if (artiste == null)
|
||||
{
|
||||
_logger.LogWarning("Artiste non trouvé pour le nom : {NomArtiste}", nomPropre);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
_logger.LogInformation("Artiste trouvé : {NomArtiste}", nom);
|
||||
|
||||
// On remplit le ViewModel
|
||||
var viewModel = new ArtisteModel
|
||||
{
|
||||
Artiste = artiste,
|
||||
Titres = artiste.Titres
|
||||
};
|
||||
|
||||
return View(viewModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
15
Webzine.WebApplication/Controllers/ContactController.cs
Normal file
15
Webzine.WebApplication/Controllers/ContactController.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Webzine.WebApplication.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// Controller pour la page contact.
|
||||
/// </summary>
|
||||
public class ContactController : Controller
|
||||
{
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Webzine.Entity;
|
||||
using Webzine.Entity.Fixtures;
|
||||
using Webzine.WebApplication.ViewsModels.Titre;
|
||||
using Webzine.WebApplication.ViewModels.Titre;
|
||||
|
||||
namespace Webzine.WebApplication.Controllers;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user