49 lines
976 B
C#
49 lines
976 B
C#
using System;
|
|
using Application;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace Website
|
|
{
|
|
public class LinksController : Controller
|
|
{
|
|
private readonly LinkService _service;
|
|
|
|
public LinksController(LinkService service)
|
|
{
|
|
_service = service;
|
|
}
|
|
|
|
public IActionResult Index()
|
|
{
|
|
// return Forbid();
|
|
return View(_service.GetAllLinks());
|
|
}
|
|
|
|
[HttpGet("{controller}/detail/{linkId:guid}")]
|
|
public IActionResult Show(Guid linkId)
|
|
{
|
|
return View(_service.GetLinkById(linkId));
|
|
}
|
|
|
|
// [HttpGet] // Implicite car HttpGet par défaut
|
|
public IActionResult Create()
|
|
{
|
|
// ViewData["Message"] = "Une valeur";
|
|
return View();
|
|
}
|
|
|
|
[HttpPost]
|
|
[ValidateAntiForgeryToken]
|
|
public IActionResult Create(PublishLinkCommand cmd)
|
|
{
|
|
if (!ModelState.IsValid)
|
|
{
|
|
return View(cmd);
|
|
}
|
|
|
|
_service.PublishLink(cmd);
|
|
|
|
return RedirectToAction(nameof(Index));
|
|
}
|
|
}
|
|
} |