using FastEndpoints;
using FrameworkBLL.Comment;
using FrameworkDAL.DTO.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.SaveCommentThread (GB5Solution/
/// Communication module, ECP Phase 1). TCOMMENT/SaveComment 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.SaveCommentThread (Communication module, ECP Phase 1). Do not use in new code.")]
public class SaveComment : BaseEndpoint>
{
private readonly ICommentBLL _commentBLL;
public SaveComment(ICommentBLL commentBLL)
{
_commentBLL = commentBLL;
}
public override void Configure()
{
Post("/Comment/SaveComment");
AllowAnonymous();
}
public record SaveCommentParameters(
[property: FromHeader] string Login,
[property: FromBody] CommentDTO CommentDTO
);
protected override async Task> ExecuteAsync(SaveCommentParameters req, LoginDTO LoginDTO, CancellationToken ct)
{
try
{
var result = await _commentBLL.SaveComment(req.CommentDTO, 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);
}
}
}
}