using FastEndpoints; using FrameworkBLL.CheckingOption; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.CheckingOption { public class GetCheckingOption : BaseEndpoint { private readonly ICheckingOptionBLL _checkingOptionBLL; public GetCheckingOption(ICheckingOptionBLL checkingOptionBLL) { _checkingOptionBLL = checkingOptionBLL; } public override void Configure() { Get("/CheckingOption/GetCheckingOption"); AllowAnonymous(); } public record GetCheckingOptionParameters( [property: QueryParam] int CheckingOptionId, [property: FromHeader] string Login ); protected override string? GetCacheKey(GetCheckingOptionParameters GetCheckingOptionParameters, LoginDTO LoginDTO) { try { return KeyGenerator.KeyGeneration(GetCheckingOptionParameters.CheckingOptionId!, EntityConstant.OBJECTCHECKINGOPTION, CacheKeyLevel.USER_LEVEL, LoginDTO); } catch (Exception) { throw; } } protected override async Task> ExecuteAsync(GetCheckingOptionParameters parameters, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _checkingOptionBLL.GetCheckingOption(parameters.CheckingOptionId, 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); } } } }