113 lines
3.3 KiB
C#
113 lines
3.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Webzine.Entity;
|
|
using Webzine.WebApplication.Areas.Administration.ViewModels;
|
|
|
|
namespace Webzine.WebApplication.Areas.Administration.Controllers
|
|
{
|
|
[Area("Administration")]
|
|
public class CommentairesController : Controller
|
|
{
|
|
// GET: Administration/Commentaires
|
|
public ActionResult Index()
|
|
{
|
|
// Création de données "bouchon" (mock) pour tester l'affichage
|
|
var listeCommentaires = new List<Commentaire>
|
|
{
|
|
new Commentaire
|
|
{
|
|
IdCommentaire = 1, // Correction: Id -> IdCommentaire
|
|
Auteur = "Michel", // Correction: Nom -> Auteur
|
|
Contenu = "Nulla sed velit nec tellus gravida molestie",
|
|
DateCreation = new DateTime(2023, 1, 22, 15, 59, 28),
|
|
// Important : On initialise l'objet Titre pour accéder à Titre.Libelle
|
|
Titre = new Titre { Libelle = "St Germain - So Flute" },
|
|
},
|
|
new Commentaire
|
|
{
|
|
IdCommentaire = 2,
|
|
Auteur = "Jeff",
|
|
Contenu = "Lorem ipsum dolor sit.",
|
|
DateCreation = new DateTime(2023, 1, 22, 14, 27, 8),
|
|
Titre = new Titre { Libelle = "Queen - Bohemian Rapsody" },
|
|
},
|
|
new Commentaire
|
|
{
|
|
IdCommentaire = 3,
|
|
Auteur = "Eva",
|
|
Contenu = "Aenean vulputate eleifend tellus.",
|
|
DateCreation = new DateTime(2023, 1, 22, 13, 2, 17),
|
|
Titre = new Titre { Libelle = "Rammstein - Du hast" },
|
|
},
|
|
};
|
|
|
|
// Initialisation du ViewModel
|
|
var viewModel = new CommentaireViewModel
|
|
{
|
|
Commentaires = listeCommentaires
|
|
};
|
|
|
|
return View(viewModel);
|
|
}
|
|
|
|
|
|
|
|
// GET: CommentairesController/Details/5
|
|
public ActionResult Details(int id)
|
|
{
|
|
return View();
|
|
}
|
|
|
|
// GET: CommentairesController/Create
|
|
public ActionResult Create()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
// POST: CommentairesController/Create
|
|
[HttpPost]
|
|
[ValidateAntiForgeryToken]
|
|
public ActionResult Create(IFormCollection collection)
|
|
{
|
|
try
|
|
{
|
|
return RedirectToAction(nameof(Index));
|
|
}
|
|
catch
|
|
{
|
|
return View();
|
|
}
|
|
}
|
|
|
|
// GET: CommentairesController/Edit/5
|
|
public ActionResult Edit(int id)
|
|
{
|
|
return View();
|
|
}
|
|
|
|
// POST: CommentairesController/Edit/5
|
|
[HttpPost]
|
|
[ValidateAntiForgeryToken]
|
|
public ActionResult Edit(int id, IFormCollection collection)
|
|
{
|
|
try
|
|
{
|
|
return RedirectToAction(nameof(Index));
|
|
}
|
|
catch
|
|
{
|
|
return View();
|
|
}
|
|
}
|
|
|
|
// GET: CommentairesController/Delete/5
|
|
public ActionResult Delete(int id)
|
|
{
|
|
return View();
|
|
}
|
|
|
|
// POST: CommentairesController/Delete/5
|
|
}
|
|
} |