using AccountsBLL.Account; using FastEndpoints; using GB5Shared.DTO.Framework.Criteria; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace AccountsSL.EndPoints.Account { public class GetSelectListAccountVsCompany : BaseEndpoint> { private readonly IAccountBLL _AccountBLL; public GetSelectListAccountVsCompany(IAccountBLL accountBLL) => _AccountBLL = accountBLL; public override void Configure() { Post("/Account/GetSelectListAccountVsCompany"); AllowAnonymous(); } public record GetSelectListAccountVsCompanyParameters( [property: FromHeader] string Login, [property: QueryParam] int FirstNumber, [property: QueryParam] int MaxResult, [property: FromBody] CriteriaDTO CriteriaDTO ); protected override string? GetCacheKey(GetSelectListAccountVsCompanyParameters req, LoginDTO login) => null; protected override async Task> ExecuteAsync( GetSelectListAccountVsCompanyParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _AccountBLL.GetSelectListAccountVsCompany( req.FirstNumber, req.MaxResult, req.CriteriaDTO, 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); } } } }