using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using RecruitmentBLL.BgVerification; using RecruitmentDAL.DTO.BgVerification; using static GB5Shared.GB5Constant.Constant; namespace RecruitmentSL.EndPoints.BgVerification { // Standalone recruiter-triggered entry point for opening BG checks on an Application — the // same BLL method JobOfferBLL.RecordOfferResponseAsync calls automatically on offer // acceptance (see that method's best-effort hook), exposed here for a recruiter to // re-trigger, or open a specific subset of CheckTypes, without needing a JobOffer response // event. public class InitiateBgVerification : BaseEndpoint> { private readonly IBgVerificationBLL _BgVerificationBLL; public InitiateBgVerification(IBgVerificationBLL bgVerificationBLL) { _BgVerificationBLL = bgVerificationBLL; } public override void Configure() { Post("/BgVerification/InitiateBgVerification"); AllowAnonymous(); } public record Parameters( [property: FastEndpoints.FromHeader] string Login, [property: FastEndpoints.FromBody] InitiateBgVerificationDTO InitiateBgVerificationDTO ); 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.InitiateBgVerification(req.InitiateBgVerificationDTO, 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); } } } }