2021-12-13 14:05:59 +01:00

34 lines
647 B
C#

using HackerNet.Application;
using HackerNet.Infrastructure.Repositories.Memory;
using Microsoft.AspNetCore.Mvc;
namespace HackerNet.Web.Controllers;
public class LinksController : Controller
{
private readonly LinkService _linkService;
public LinksController(LinkService linkService)
{
_linkService = linkService;
}
[HttpGet]
public IActionResult New()
{
return View(new PublishLinkCommand());
}
[HttpPost]
public IActionResult New(PublishLinkCommand cmd)
{
if (!ModelState.IsValid)
{
return View(cmd);
}
_linkService.PublishLink(cmd);
return RedirectToAction("Index", "Home");
}
}