using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using RecruitmentBLL.BgVerification; using static GB5Shared.GB5Constant.Constant; namespace RecruitmentSL.EndPoints.BgVerification { public class GetBgVerification : BaseEndpoint { private readonly IBgVerificationBLL _BgVerificationBLL; public GetBgVerification(IBgVerificationBLL bgVerificationBLL) { _BgVerificationBLL = bgVerificationBLL; } public override void Configure() { Get("/BgVerification/GetBgVerification"); // Roles("HR", "Recruiter") throws 500 here — no host in this repo configures // AddAuthentication (see PayRollSL's GetHRMSDashboard.cs for the same documented, // repo-wide gap). AllowAnonymous matches every other endpoint in this SL module. AllowAnonymous(); } public record Parameters( [property: QueryParam] int BgVerificationId, [property: FastEndpoints.FromHeader] string Login ); protected override string? GetCacheKey(Parameters req, LoginDTO login) => KeyGenerator.KeyGeneration( req.BgVerificationId, EntityConstant.OBJECTRECRUITMENTBGVERIFICATION, CacheKeyLevel.CLIENT_LEVEL, login); protected override async Task> ExecuteAsync( Parameters req, LoginDTO login, CancellationToken ct) { try { var result = await _BgVerificationBLL.GetBgVerification(req.BgVerificationId, login!, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.CLIENT_LEVEL, login); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.CLIENT_LEVEL, login, ex.Message, 500); } } } }