using Microsoft.AspNetCore.Mvc; using HN.Application; using MediatR; using System.Threading.Tasks; namespace Website.Controllers { public class LinksController : Controller { private readonly IMediator _bus; public LinksController(IMediator bus) { _bus = bus; } public IActionResult Index() { return View(); } public IActionResult Create() { return View(new AddLinkCommand()); } [HttpPost] [ValidateAntiForgeryToken] public async Task Create(AddLinkCommand command) { if (!ModelState.IsValid) { return View(command); } await _bus.Send(command); return RedirectToAction(nameof(Index)); } } }