using CRMBLL.Action; using CRMSL.EndPoints.Task; using FastEndpoints; using GB5Shared.DTO.Framework.Criteria; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.DTO.Report; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace CRMSL.EndPoints.Action { public class GetActivityRegisterReport : BaseEndpoint> { private readonly IActionBLL _ActionBLL; public GetActivityRegisterReport(IActionBLL ActionBLL) => _ActionBLL = ActionBLL; public override void Configure() { Post("/Action/GetActivityRegisterReport"); AllowAnonymous(); } public record Parameters( [property: FromHeader] string Login, [property: QueryParam] int FirstNumber, [property: QueryParam] int MaxResult, [property: FromBody] ReportCallingDTO ReportCallingDTO ); protected override string? GetCacheKey(Parameters req, LoginDTO login) => null; protected override async Task> ExecuteAsync(Parameters req, LoginDTO LoginDTO, CancellationToken ct) { try { if (req.ReportCallingDTO?.CriteriaDTO == null)throw new ArgumentException("CriteriaDTO is required."); var data = await _ActionBLL.GetActivityRegisterReport(req.FirstNumber,req.MaxResult,req.ReportCallingDTO.CriteriaDTO,LoginDTO); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(data, CacheKeyLevel.NOT_REQUIRED, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.NOT_REQUIRED, LoginDTO, ex.Message, 500); } } } }