using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using PayRollBLL.ShiftPattern; using static GB5Shared.GB5Constant.Constant; namespace PayRollSL.EndPoints.ShiftPattern { // Sub-endpoint powering the shift-pattern detail grid: loads every detail row (through its // days rows) for a single ShiftPatternId, without re-fetching the whole header/days hierarchy // via GetShiftPattern. public class LoadShiftPatternDetails : BaseEndpoint> { private readonly IShiftPatternBLL _ShiftPatternBLL; public LoadShiftPatternDetails(IShiftPatternBLL shiftPatternBLL) { _ShiftPatternBLL = shiftPatternBLL; } public override void Configure() { Get("/ShiftPattern/LoadShiftPatternDetails"); AllowAnonymous(); } public record LoadShiftPatternDetailsParameters( [property: FromHeader] string Login, [property: QueryParam] int ShiftPatternId ); protected override string? GetCacheKey(LoadShiftPatternDetailsParameters req, LoginDTO loginDTO) { try { return KeyGenerator.KeyGeneration(req.ShiftPatternId, EntityConstant.OBJECTSHIFTPATTERN, CacheKeyLevel.USER_LEVEL, loginDTO); } catch (Exception) { throw; } } protected override async Task> ExecuteAsync( LoadShiftPatternDetailsParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _ShiftPatternBLL.LoadShiftPatternDetails(req.ShiftPatternId, 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); } } } }