using CRMBLL.SLA; using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace CRMSL.EndPoints.SLA { public class GetSLA : BaseEndpoint { private readonly ISLABLL _SLABLL; public GetSLA(ISLABLL SLABLL) { _SLABLL = SLABLL; } public override void Configure() { Get("/SLA/GetSLA"); AllowAnonymous(); } public record GetSLAParameters( [property: QueryParam] int SLAId, [property: FromHeader] string Login ); protected override string? GetCacheKey(GetSLAParameters parameters, LoginDTO LoginDTO) { try { return KeyGenerator.KeyGeneration(parameters.SLAId!, EntityConstant.OBJECTSERVICELEVELAGREEMENT, CacheKeyLevel.USER_LEVEL, LoginDTO); } catch (Exception) { throw; } } protected override async Task> ExecuteAsync(GetSLAParameters parameters, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _SLABLL.GetSLA(parameters.SLAId, 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); } } } }