using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using RecruitmentBLL.CandidateConversion; using RecruitmentDAL.DTO.CandidateConversion; using static GB5Shared.GB5Constant.Constant; namespace RecruitmentSL.EndPoints.CandidateConversion { // The Candidate->Employee "final joining event" (Phase 3 of the Recruitment build-out plan) // — see RecruitmentBLL.CandidateConversion.CandidateConversionBLL's class doc comment for the // full flow and the terminal-stage/hire-outcome validation performed before calling // PayRollBLL.Employee.IEmployeeBLL.SaveEmployee. public class ConvertCandidateToEmployee : BaseEndpoint> { private readonly ICandidateConversionBLL _CandidateConversionBLL; public ConvertCandidateToEmployee(ICandidateConversionBLL candidateConversionBLL) { _CandidateConversionBLL = candidateConversionBLL; } public override void Configure() { Post("/CandidateConversion/ConvertCandidateToEmployee"); // Roles("HR", "Recruiter") throws 500 here — no host in this repo configures // AddAuthentication (HRFinanceHost included; see PayRollSL's GetHRMSDashboard.cs / // RecruitmentSL's SaveCandidate.cs for the same documented, repo-wide gap). // AllowAnonymous matches every other endpoint in this SL module today. AllowAnonymous(); } public record ConvertCandidateToEmployeeParameters( [property: FastEndpoints.FromHeader] string Login, [property: FastEndpoints.FromBody] CandidateConversionRequestDTO CandidateConversionRequestDTO ); // Mutation endpoint — never cached. protected override string? GetCacheKey(ConvertCandidateToEmployeeParameters req, LoginDTO login) => null; protected override async Task> ExecuteAsync( ConvertCandidateToEmployeeParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _CandidateConversionBLL .ConvertCandidateToEmployeeAsync(req.CandidateConversionRequestDTO, LoginDTO!, ct); return await GB5Shared.ResponseStandard.Response .CreateSuccessResponse( result, CacheKeyLevel.NOT_REQUIRED, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response .CreateExceptionError( ex, CacheKeyLevel.NOT_REQUIRED, LoginDTO, ex.Message, 500); } } } }