using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using CRMSalesBLL.LeadScoringConfig; using static GB5Shared.GB5Constant.Constant; namespace CRMSalesSL.EndPoints.LeadScoringConfig; public class GetLeadScoringConfig : BaseEndpoint> { private readonly ILeadScoringConfigBLL _LeadScoringConfigBLL; public GetLeadScoringConfig(ILeadScoringConfigBLL leadScoringConfigBLL) => _LeadScoringConfigBLL = leadScoringConfigBLL; public override void Configure() { Get("/LeadScoringConfig/GetLeadScoringConfig"); AllowAnonymous(); } public record GetLeadScoringConfigParameters( [property: QueryParam] int LeadScoringConfigId, [property: FromHeader] string Login ); protected override string? GetCacheKey(GetLeadScoringConfigParameters req, LoginDTO login) => KeyGenerator.KeyGeneration(req.LeadScoringConfigId, EntityConstant.OBJECTCRMSALESLEADSCORINGCONFIG, CacheKeyLevel.CLIENT_LEVEL, login); protected override async Task> ExecuteAsync(GetLeadScoringConfigParameters req, LoginDTO login, CancellationToken ct) { try { var result = await _LeadScoringConfigBLL.GetLeadScoringConfig(req.LeadScoringConfigId, login!, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.CLIENT_LEVEL, login); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.CLIENT_LEVEL, login, ex.Message, 500); } } }