using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using GB5Shared.ListQuery; using PIEDAL.DTO.Outcome; using static GB5Shared.GB5Constant.Constant; namespace PIESL.EndPoints.Outcome { public class GetPIEOutcomeList : BaseEndpoint> { private readonly IListHandler _ListHandler; public GetPIEOutcomeList(IListHandler listHandler) { _ListHandler = listHandler; } public override void Configure() { Post("/PIE/GetPIEOutcomeList"); AllowAnonymous(); } public record Params( [property: FromHeader] string Login, [property: QueryParam] Guid? ModuleId = null, [property: QueryParam] Guid? ProfileId = null, [property: QueryParam] string? Industry = null, [property: QueryParam] string? Geography = null, [property: QueryParam] short? EngagementType = null, [property: QueryParam] bool? GoLiveSuccess = null, [property: QueryParam] string? SortBy = null, [property: QueryParam] bool SortDesc = false, [property: QueryParam] int PageOffset = 0, [property: QueryParam] int PageSize = 100 ); protected override string? GetCacheKey(Params req, LoginDTO loginDTO) => null; protected override async Task> ExecuteAsync(Params req, LoginDTO loginDTO, CancellationToken ct) { var criteria = new PIEOutcomeListCriteria { ModuleId = req.ModuleId, ProfileId = req.ProfileId, Industry = req.Industry, Geography = req.Geography, EngagementType = req.EngagementType, GoLiveSuccess = req.GoLiveSuccess is null ? null : (short?)(req.GoLiveSuccess.Value ? 1 : 0), SortBy = req.SortBy, SortDesc = req.SortDesc, PageOffset = req.PageOffset, PageSize = req.PageSize }; var result = await _ListHandler.HandleAsync(new PIEOutcomeListQuery(criteria), loginDTO, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.NOT_REQUIRED, loginDTO); } } }