using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using MMBLL.Scheduling; using static GB5Shared.GB5Constant.Constant; namespace MMSL.EndPoints.Scheduling { public class GetResourcePlan : BaseEndpoint> { private readonly ISchedulingRunBLL _SchedulingRunBLL; public GetResourcePlan(ISchedulingRunBLL schedulingRunBLL) { _SchedulingRunBLL = schedulingRunBLL; } public override void Configure() { Get("/Scheduling/GetResourcePlan"); AllowAnonymous(); } public record GetResourcePlanParameters( [property: FromHeader] string Login, [property: QueryParam] int IndentDetailId ); // Live schedule data — not cached protected override string? GetCacheKey(GetResourcePlanParameters req, LoginDTO loginDTO) => null; protected override async Task> ExecuteAsync( GetResourcePlanParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _SchedulingRunBLL.GetResourcePlanByIndent(req.IndentDetailId, 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); } } } }