using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using PayRollBLL.OverTime; using static GB5Shared.GB5Constant.Constant; namespace PayRollSL.EndPoints.OverTime { // GB4 route: OverTime.svc/?OverTimeId={OverTimeId} (GET) — Get(int OverTimeId). public class GetOverTime : BaseEndpoint> { private readonly IOverTimeBLL _OverTimeBLL; public GetOverTime(IOverTimeBLL OverTimeBLL) { _OverTimeBLL = OverTimeBLL; } public override void Configure() { Get("/OverTime/GetOverTime"); AllowAnonymous(); } public record GetOverTimeParameters( [property: QueryParam] int OverTimeId, [property: FromHeader] string Login ); protected override async Task> ExecuteAsync( GetOverTimeParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _OverTimeBLL.Get(req.OverTimeId, loginDTO); 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); } } } }