using System; using Application; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; namespace Api.Controllers { [Route("api/[controller]")] [ApiController] public class CommentsController : ControllerBase { private readonly CommentService _commentService; public CommentsController(CommentService commentService) { _commentService = commentService; } /// /// Affiche un commentaire. /// /// /// [HttpGet("{id:guid}")] [ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status200OK)] public CommentDTO Show(Guid id) { return _commentService.GetCommentById(id); } /// /// Publie un nouveau commentaire sur la plateforme. /// /// /// [HttpPost] [ProducesResponseType(StatusCodes.Status400BadRequest)] [ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status201Created)] public IActionResult Create(PublishCommentCommand cmd) { var commentId = _commentService.PublishComment(cmd); return CreatedAtAction(nameof(Show), new { id = commentId }, null); } } }