using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using PayRollBLL.GateEntry; using static GB5Shared.GB5Constant.Constant; namespace PayRollSL.EndPoints.GateEntry { public class DeleteGateEntry : BaseEndpoint> { private readonly IGateEntryBLL _GateEntryBLL; public DeleteGateEntry(IGateEntryBLL gateEntryBLL) { _GateEntryBLL = gateEntryBLL; } public override void Configure() { Delete("/GateEntry/DeleteGateEntry"); AllowAnonymous(); } public record DeleteGateEntryParameters( [property: FromHeader] string Login, [property: QueryParam] int GateEntryId ); protected override string? GetCacheKey(DeleteGateEntryParameters req, LoginDTO loginDTO) => null; protected override async Task> ExecuteAsync( DeleteGateEntryParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _GateEntryBLL.DeleteGateEntry(req.GateEntryId, loginDTO); 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); } } } }