using FastEndpoints; using GB5Shared.DTO.Framework.Criteria; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using RecruitmentBLL.FlsAction; using static GB5Shared.GB5Constant.Constant; namespace RecruitmentSL.EndPoints.FlsAction { public class GetSelectListFlsAction : BaseEndpoint> { private readonly IRecruitmentFlsActionBLL _RecruitmentFlsActionBLL; public GetSelectListFlsAction(IRecruitmentFlsActionBLL recruitmentFlsActionBLL) { _RecruitmentFlsActionBLL = recruitmentFlsActionBLL; } public override void Configure() { Post("/FlsAction/GetSelectListFlsAction"); // Roles("HR", "Recruiter", "Manager") 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 GetSelectListFlsActionParameters( [property: FastEndpoints.FromHeader] string Login, [property: FastEndpoints.FromBody] CriteriaDTO CriteriaDTO ); // NOT_REQUIRED: PrepareActionAsync/SubmitActionAsync can add/update a row in this list at // any moment — a cached response here would show a stale action list to an admin/audit // screen right after a dispatch or a candidate response. protected override string? GetCacheKey(GetSelectListFlsActionParameters req, LoginDTO login) => null; protected override async Task> ExecuteAsync( GetSelectListFlsActionParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _RecruitmentFlsActionBLL .GetSelectListRecruitmentFlsAction(req.CriteriaDTO, 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); } } } }