25 lines
678 B
C#
25 lines
678 B
C#
using Femto.Api.Controllers.Posts.Dto;
|
|
using Femto.Modules.Blog.Domain.Posts.Commands.CreatePost;
|
|
using MediatR;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace Femto.Api.Controllers.Posts;
|
|
|
|
[ApiController]
|
|
[Route("posts")]
|
|
public class PostsController(IMediator mediator) : ControllerBase
|
|
{
|
|
[HttpPost]
|
|
public async Task<ActionResult<CreatePostResponse>> Post(
|
|
[FromBody] CreatePostRequest req,
|
|
CancellationToken cancellationToken
|
|
)
|
|
{
|
|
var guid = await mediator.Send(
|
|
new CreatePostCommand(req.AuthorId, req.Content, req.Media),
|
|
cancellationToken
|
|
);
|
|
|
|
return new CreatePostResponse(guid);
|
|
}
|
|
}
|