using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using PayRollBLL.Employee; using static GB5Shared.GB5Constant.Constant; namespace PayRollSL.EndPoints.Employee { // No explicit rights-check here — matches sibling GetEmployee.cs, which relies purely on // AllowAnonymous() + upstream gateway auth rather than an in-endpoint CheckUserRights call. public class GetEmployeeVersion : BaseEndpoint> { private readonly IEmployeeBLL _EmployeeBLL; public GetEmployeeVersion(IEmployeeBLL employeeBLL) { _EmployeeBLL = employeeBLL; } public override void Configure() { Get("/Employee/Version"); AllowAnonymous(); } public record Params( [property: FromHeader] string Login, [property: QueryParam] int EmployeeVersionId ); protected override async Task> ExecuteAsync(Params req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _EmployeeBLL.GetEmployeeVersion(req.EmployeeVersionId, 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); } } } }