using FastEndpoints; using GB5Shared.DTO.Framework.Criteria; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using PartnerBLL.PartnerProduct; using static GB5Shared.GB5Constant.Constant; namespace PartnerSL.EndPoints.PartnerProduct { public class GetSelectListPartnerProduct : BaseEndpoint> { private readonly IPartnerProductBLL _partnerProductBLL; public GetSelectListPartnerProduct(IPartnerProductBLL partnerProductBLL) => _partnerProductBLL = partnerProductBLL; public override void Configure() { Post("/PartnerProduct/GetSelectListPartnerProduct"); AllowAnonymous(); } public record GetSelectListPartnerProductParameters( [property: FromHeader] string Login, [property: FromBody] CriteriaDTO CriteriaDTO ); protected override string? GetCacheKey(GetSelectListPartnerProductParameters req, LoginDTO loginDTO) => KeyGenerator.KeyGeneration("selectlist", EntityConstant.OBJECTPARTNERPRODUCT, CacheKeyLevel.OVERALL, loginDTO, req.CriteriaDTO); protected override async Task> ExecuteAsync( GetSelectListPartnerProductParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _partnerProductBLL.GetSelectListPartnerProduct(req.CriteriaDTO, loginDTO, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.OVERALL, loginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.OVERALL, loginDTO, ex.Message, 500); } } } }