using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using MarketingBLL.ICP; using static GB5Shared.GB5Constant.Constant; namespace MarketingSL.EndPoints.ICP; public class GetICP : BaseEndpoint> { private readonly IICPBLL _ICPBLL; public GetICP(IICPBLL icpBLL) => _ICPBLL = icpBLL; public override void Configure() { Get("/ICP/GetICP"); AllowAnonymous(); } public record GetICPParameters( [property: QueryParam] int ICPId, [property: FromHeader] string Login ); protected override string? GetCacheKey(GetICPParameters req, LoginDTO login) => KeyGenerator.KeyGeneration(req.ICPId, EntityConstant.OBJECTMARKETINGICP, CacheKeyLevel.CLIENT_LEVEL, login); protected override async Task> ExecuteAsync(GetICPParameters req, LoginDTO login, CancellationToken ct) { try { var result = await _ICPBLL.GetICP(req.ICPId, 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); } } }