using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using MarketingBLL.LeadSource; using static GB5Shared.GB5Constant.Constant; namespace MarketingSL.EndPoints.LeadSource { public class GetLeadSource : BaseEndpoint> { private readonly ILeadSourceBLL _LeadSourceBLL; public GetLeadSource(ILeadSourceBLL LeadSourceBLL) { _LeadSourceBLL = LeadSourceBLL; } public override void Configure() { Get("/LeadSource/GetLeadSource"); AllowAnonymous(); } public record GetLeadSourceParameters( [property: QueryParam] int LeadSourceId, [property: FromHeader] string Login ); protected override string? GetCacheKey(GetLeadSourceParameters parameters, LoginDTO LoginDTO) { try { return KeyGenerator.KeyGeneration(parameters.LeadSourceId!, EntityConstant.OBJECTLEADSOURCE, CacheKeyLevel.USER_LEVEL, LoginDTO); } catch (Exception) { throw; } } protected override async Task> ExecuteAsync(GetLeadSourceParameters parameters, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _LeadSourceBLL.GetLeadSource(parameters.LeadSourceId, 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); } } } }