using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using PayRollBLL.TLeave; using PayRollDAL.DTO.TLeave; using static GB5Shared.GB5Constant.Constant; namespace PayRollSL.EndPoints.TLeave { public class SaveTLeave : BaseEndpoint> { private readonly ITLeaveBLL _TLeaveBLL; public SaveTLeave(ITLeaveBLL tLeaveBLL) { _TLeaveBLL = tLeaveBLL; } public override void Configure() { Post("/TLeave/SaveTLeave"); AllowAnonymous(); } public record SaveTLeaveParameters( [property: FromHeader] string Login, [property: FromBody] TLeaveDTO TLeaveDTO ); protected override string? GetCacheKey(SaveTLeaveParameters req, LoginDTO login) => null; protected override async Task> ExecuteAsync( SaveTLeaveParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _TLeaveBLL.SaveTLeave(req.TLeaveDTO, 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); } } } }