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