using MMBLL.TransactionType; using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace MMSL.EndPoints.TransactionType { public class GetTransactionType : BaseEndpoint> { private readonly ITransactionTypeBLL _TransactionTypeBLL; public GetTransactionType(ITransactionTypeBLL TransactionTypeBLL) { _TransactionTypeBLL = TransactionTypeBLL; } public override void Configure() { Get("/TransactionType/GetTransactionType"); AllowAnonymous(); } public record GetTransactionTypeParameters( [property: FromHeader] string Login, [property: QueryParam] int TransactionTypeId ); protected override string? GetCacheKey(GetTransactionTypeParameters Parameters, LoginDTO LoginDTO) { try { return KeyGenerator.KeyGeneration( Parameters.TransactionTypeId!, EntityConstant.TRANSACTIONTYPE, CacheKeyLevel.USER_LEVEL, LoginDTO ); } catch (Exception) { throw; } } protected override async Task> ExecuteAsync(GetTransactionTypeParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _TransactionTypeBLL.GetTransactionType(req.TransactionTypeId, 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 ); } } } }