using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using RecruitmentBLL.Interview; using System.Threading; using static GB5Shared.GB5Constant.Constant; namespace RecruitmentSL.Endpoints.Interview { public class GetInterview : BaseEndpoint { private readonly IInterviewBLL _InterviewBLL; public GetInterview(IInterviewBLL InterviewBLL) { _InterviewBLL = InterviewBLL; } public override void Configure() { Get("/Interview/GetInterview"); // Roles("User") throws 500 here — no host in this repo configures AddAuthentication, // so FastEndpoints has no scheme to challenge against (repo-wide gap, not specific to // this endpoint — see PayRollSL/EndPoints/Employee/GetHRMSDashboard.cs for the same // documented finding). AllowAnonymous matches every other endpoint in this SL module. AllowAnonymous(); } public record GetInterviewParameters( [property: QueryParam] int InterviewId, [property: FromHeader] string Login ); protected override string? GetCacheKey(GetInterviewParameters GetInterviewParameters, LoginDTO LoginDTO) { try { return KeyGenerator.KeyGeneration( GetInterviewParameters.InterviewId, EntityConstant.OBJECTRECRUITMENTINTERVIEW, CacheKeyLevel.CLIENT_LEVEL, LoginDTO); } catch (Exception) { throw; } } protected override async Task> ExecuteAsync(GetInterviewParameters parameters, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _InterviewBLL.GetInterview(parameters.InterviewId, loginDTO!, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.USER_LEVEL, loginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.USER_LEVEL, loginDTO, ex.Message, 500); } } } }