using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using RecruitmentBLL.Referral; using static GB5Shared.GB5Constant.Constant; namespace RecruitmentSL.EndPoints.Referral { public class GetReferral : BaseEndpoint { private readonly IReferralBLL _ReferralBLL; public GetReferral(IReferralBLL referralBLL) { _ReferralBLL = referralBLL; } public override void Configure() { Get("/Referral/GetReferral"); // Roles() 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 ReferralId, [property: FastEndpoints.FromHeader] string Login ); protected override string? GetCacheKey(Parameters req, LoginDTO login) => KeyGenerator.KeyGeneration( req.ReferralId, EntityConstant.OBJECTRECRUITMENTREFERRAL, CacheKeyLevel.CLIENT_LEVEL, login); protected override async Task> ExecuteAsync( Parameters req, LoginDTO login, CancellationToken ct) { try { var result = await _ReferralBLL.GetReferral(req.ReferralId, 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); } } } }