using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using Microsoft.AspNetCore.Mvc; using RecruitmentBLL.Application; using System.Collections.Generic; using static GB5Shared.GB5Constant.Constant; namespace RecruitmentSL.EndPoints.Application { /// Thin passthrough to ECP's CommentThread feature (hosted by EngagementHost) via /// ApplicationBLL.PostApplicationComment / IEcpIntegrationService — no CommentThread data is /// persisted in Recruitment's own schema. public class PostApplicationComment : BaseEndpoint> { private readonly IApplicationBLL _ApplicationBLL; public PostApplicationComment(IApplicationBLL applicationBLL) { _ApplicationBLL = applicationBLL; } public override void Configure() { Post("/Application/PostApplicationComment"); // Roles("HR", "Recruiter", "Interviewer") throws 500 here — no host in this repo // configures AddAuthentication (HRFinanceHost included; see PayRollSL's // GetHRMSDashboard.cs for the same documented, repo-wide gap). AllowAnonymous // matches every other endpoint in this SL module today. AllowAnonymous(); } public record PostApplicationCommentRequestDTO( int ApplicationId, string CommentText, List? MentionedUserIds ); public record PostApplicationCommentParameters( [property: FastEndpoints.FromHeader] string Login, [property: FastEndpoints.FromBody] PostApplicationCommentRequestDTO Comment ); protected override string? GetCacheKey(PostApplicationCommentParameters req, LoginDTO login) => null; protected override async Task> ExecuteAsync( PostApplicationCommentParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _ApplicationBLL.PostApplicationComment( req.Comment.ApplicationId, req.Comment.CommentText, req.Comment.MentionedUserIds ?? new List(), LoginDTO!, ct); 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); } } } }