using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using PartnerBLL.PartnerBrand; using static GB5Shared.GB5Constant.Constant; namespace PartnerSL.EndPoints.PartnerProductBrand { public class GetPartnerProductBrand : BaseEndpoint> { private readonly IPartnerBrandBLL _partnerBrandBLL; public GetPartnerProductBrand(IPartnerBrandBLL partnerBrandBLL) => _partnerBrandBLL = partnerBrandBLL; public override void Configure() { Get("/PartnerProductBrand/GetPartnerProductBrand"); AllowAnonymous(); } public record GetPartnerProductBrandParameters( [property: FromHeader] string Login, [property: QueryParam] int PartnerProductId ); protected override string? GetCacheKey(GetPartnerProductBrandParameters req, LoginDTO loginDTO) => KeyGenerator.KeyGeneration(req.PartnerProductId, EntityConstant.OBJECTPARTNERPRODUCTBRAND, CacheKeyLevel.OVERALL, loginDTO); protected override async Task> ExecuteAsync( GetPartnerProductBrandParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _partnerBrandBLL.GetPartnerProductBrand(req.PartnerProductId, loginDTO); 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); } } } }