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