using FastEndpoints; using GB5Shared.DTO.Framework.Criteria; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using Microsoft.AspNetCore.Mvc; using RecruitmentBLL.SelectionProcess; using static GB5Shared.GB5Constant.Constant; namespace RecruitmentSL.EndPoints.SelectionProcess { public class GetSelectListSelectionProcessTemplate : BaseEndpoint< GetSelectListSelectionProcessTemplate.GetSelectListSelectionProcessTemplateParameters, ResponseStandardDTO> { private readonly ISelectionProcessBLL _SelectionProcessBLL; public GetSelectListSelectionProcessTemplate(ISelectionProcessBLL selectionProcessBLL) { _SelectionProcessBLL = selectionProcessBLL; } public override void Configure() { Post("/SelectionProcess/GetSelectListSelectionProcessTemplate"); // Roles("HR", "Recruiter", "Manager") throws 500 here — no host in this repo // configures AddAuthentication (HRFinanceHost included; see PayRollSL's // GetHRMSDashboard.cs for the same documented, repo-wide gap). AllowAnonymous // matches every other endpoint in this SL module today. AllowAnonymous(); } public record GetSelectListSelectionProcessTemplateParameters( [property: FastEndpoints.FromHeader] string Login, [property: FastEndpoints.FromBody] CriteriaDTO CriteriaDTO ); protected override string? GetCacheKey(GetSelectListSelectionProcessTemplateParameters req, LoginDTO login) => KeyGenerator.KeyGeneration( -1, EntityConstant.OBJECTRECRUITMENTSELECTIONPROCESSTEMPLATE, CacheKeyLevel.CLIENT_LEVEL, login); protected override async Task> ExecuteAsync( GetSelectListSelectionProcessTemplateParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _SelectionProcessBLL .GetSelectListSelectionProcessTemplate(req.CriteriaDTO, LoginDTO!, ct); return await GB5Shared.ResponseStandard.Response .CreateSuccessResponse( result, CacheKeyLevel.CLIENT_LEVEL, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response .CreateExceptionError( ex, CacheKeyLevel.CLIENT_LEVEL, LoginDTO, ex.Message, 500); } } } }