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 { // The "BG verification panel" for one Application — every concurrent check (Education/ // Employment/Criminal/Reference), newest first. public class GetSelectListBgVerification : BaseEndpoint { private readonly IBgVerificationBLL _BgVerificationBLL; public GetSelectListBgVerification(IBgVerificationBLL bgVerificationBLL) { _BgVerificationBLL = bgVerificationBLL; } public override void Configure() { Get("/BgVerification/GetSelectListBgVerification"); AllowAnonymous(); } public record Parameters( [property: QueryParam] int ApplicationId, [property: FastEndpoints.FromHeader] string Login ); // NOT_REQUIRED: InitiateBgVerification/SaveBgVerification can add/change a row for this // Application at any moment — a cached response here would show a stale check list. protected override string? GetCacheKey(Parameters req, LoginDTO login) => null; protected override async Task> ExecuteAsync( Parameters req, LoginDTO login, CancellationToken ct) { try { var result = await _BgVerificationBLL.GetSelectListBgVerification(req.ApplicationId, login!, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.NOT_REQUIRED, login); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.NOT_REQUIRED, login, ex.Message, 500); } } } }