using System.Threading.Tasks;
using HN.Application;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace Api.Controllers
{
[ApiController]
[Route("api/[controller]")]
public sealed class LinksController : ControllerBase
{
private readonly IMediator _bus;
public LinksController(IMediator bus)
{
_bus = bus;
}
///
/// Retrieve all links already posted.
///
///
[ProducesResponseType(typeof(LinkDto[]), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
public async Task GetLinks()
{
return Ok(await _bus.Send(new ListLinksQuery()));
}
///
/// Post a new link.
///
///
///
[HttpPost]
public async Task CreateLink(AddLinkCommand command)
{
var result = await _bus.Send(command);
return Created("blabla", result);
}
}
}