using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using PayRollBLL.Punch; using static GB5Shared.GB5Constant.Constant; namespace PayRollSL.EndPoints.Punch { public class MissingPunchInsert : BaseEndpoint> { private readonly IPunchBLL _PunchBLL; public MissingPunchInsert(IPunchBLL PunchBLL) { _PunchBLL = PunchBLL; } public override void Configure() { Get("/Punch/MissingPunchInsert"); AllowAnonymous(); } public record Params( [property: FromHeader] string Login, [property: QueryParam] int EmployeeId, [property: QueryParam] string FromDate, [property: QueryParam] string ToDate); protected override string? GetCacheKey(Params req, LoginDTO LoginDTO) => null; protected override async Task> ExecuteAsync(Params req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _PunchBLL.MissingPunchInsert(req.EmployeeId, req.FromDate, req.ToDate, 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); } } } public class MissingPunchInsertNew : BaseEndpoint> { private readonly IPunchBLL _PunchBLL; public MissingPunchInsertNew(IPunchBLL PunchBLL) { _PunchBLL = PunchBLL; } public override void Configure() { Get("/Punch/MissingPunchInsertNew"); AllowAnonymous(); } public record Params( [property: FromHeader] string Login, [property: QueryParam] int EmployeeId, [property: QueryParam] string FromDate, [property: QueryParam] string ToDate); protected override string? GetCacheKey(Params req, LoginDTO LoginDTO) => null; protected override async Task> ExecuteAsync(Params req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _PunchBLL.MissingPunchInsertNew(req.EmployeeId, req.FromDate, req.ToDate, 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); } } } }