using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using TMSBLL.TrainingPlanDashboard; using static GB5Shared.GB5Constant.Constant; namespace TMSSL.EndPoints.TrainingPlanDashboard { public class GetTrainingPlanDashboard : BaseEndpoint> { private readonly ITrainingPlanDashboardBLL _BLL; public GetTrainingPlanDashboard(ITrainingPlanDashboardBLL bll) { _BLL = bll; } public override void Configure() { Get("/TrainingPlanDashboard/GetTrainingPlanDashboard"); AllowAnonymous(); } public record Params( // Optional: pass a specific domain ID to filter the full dashboard // and include the complete employee list for that domain. // Leave 0 or omit to get the full organisation-wide view. [property: QueryParam] int TrainingDomainId, // PDF header fields — not stored in DB; caller supplies them from the physical plan document. // e.g. UpdationResponsibility = "Line Incharge" [property: QueryParam] string? UpdationResponsibility, // e.g. ReviewFrequency = "Every month / If new Associate join" [property: QueryParam] string? ReviewFrequency, [property: FromHeader] string Login ); protected override string? GetCacheKey(Params req, LoginDTO loginDTO) => null; protected override async Task> ExecuteAsync(Params req, LoginDTO loginDTO, CancellationToken ct) { try { int? domainId = req.TrainingDomainId > 0 ? req.TrainingDomainId : null; var result = await _BLL.GetTrainingPlanDashboard(domainId, loginDTO, req.UpdationResponsibility, req.ReviewFrequency); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.CLIENT_LEVEL, loginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.CLIENT_LEVEL, loginDTO, ex.Message, 500); } } } }