using FastEndpoints;
using FrameworkBLL.Comment;
using GB5Shared.DTO.Framework.Login;
using GB5Shared.DTO.Framework.ResponseStandard;
using GB5Shared.FastEndPoint;
using static GB5Shared.GB5Constant.Constant;
namespace FrameworkSL.Endpoints.Comment
{
///
/// Superseded by CommunicationSL.Endpoints.CommentThread.DeleteCommentThread (GB5Solution/
/// Communication module, ECP Phase 1). TCOMMENT/DeleteComment has no callers outside
/// GB5Framework (confirmed by repo-wide grep during Phase 1 planning) — kept only in case of
/// an undiscovered caller. Do not add new callers.
///
[Obsolete("Superseded by CommunicationSL.Endpoints.CommentThread.DeleteCommentThread (Communication module, ECP Phase 1). Do not use in new code.")]
public class DeleteComment : BaseEndpoint>
{
private readonly ICommentBLL _CommentBLL;
public DeleteComment(ICommentBLL commentBLL)
{
_CommentBLL = commentBLL;
}
public override void Configure()
{
Delete("/Comment/DeleteComment");
AllowAnonymous();
}
public record DeleteCommentParameters(
[property: FromHeader] string Login,
[property: QueryParam] int CommentId
);
protected override async Task> ExecuteAsync(DeleteCommentParameters req, LoginDTO loginDTO, CancellationToken ct)
{
try
{
var result = await _CommentBLL.DeleteComment(req.CommentId, loginDTO!);
return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.NOT_REQUIRED, loginDTO);
}
catch (Exception ex)
{
return await GB5Shared.ResponseStandard.Response.CreateExceptionError(
ex,
CacheKeyLevel.NOT_REQUIRED,
loginDTO,
ex.Message,
500
);
}
}
}
}