using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using PayRollBLL.MonthlyAttendance; using System; using System.Threading; using System.Threading.Tasks; using static GB5Shared.GB5Constant.Constant; namespace PayRollSL.EndPoints.MonthlyAttendance { public class GetMonthlyAttendance : BaseEndpoint { private readonly IMonthlyAttendanceBLL _monthlyAttendanceBLL; public GetMonthlyAttendance(IMonthlyAttendanceBLL monthlyAttendanceBLL) { _monthlyAttendanceBLL = monthlyAttendanceBLL; } public override void Configure() { Get("/MonthlyAttendance/GetMonthlyAttendance"); AllowAnonymous(); } public record GetMonthlyAttendanceParameters([property: QueryParam] int MonthlyAttendanceId, [property: FromHeader] string Login); protected override async Task> ExecuteAsync(GetMonthlyAttendanceParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _monthlyAttendanceBLL.GetMonthlyAttendance(req.MonthlyAttendanceId, 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); } } } }