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