using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using PayRollBLL.Leave; using PayRollDAL.DTO.Leave; using static GB5Shared.GB5Constant.Constant; namespace PayRollSL.EndPoints.Leave { public class SaveLeave : BaseEndpoint> { private readonly ILeaveBLL _LeaveBLL; public SaveLeave(ILeaveBLL ILeaveBLL) { _LeaveBLL = ILeaveBLL; } public override void Configure() { Post("/Leave/SaveLeave"); AllowAnonymous(); } public record SaveLeaveParameters( [property: FromHeader] string Login, [property: FromBody] LeaveDTO LeaveDTO ); protected override async Task> ExecuteAsync(SaveLeaveParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _LeaveBLL.SaveLeave(req.LeaveDTO, 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); } } } }