using AccountsBLL.BankBranch; using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static AccountsSL.EndPoints.AccountGroup.GetAccountGroup; using static GB5Shared.GB5Constant.Constant; namespace AccountsSL.EndPoints.BankBranch { public class GetBankBranch : BaseEndpoint> { private readonly IBankBranchBLL _BankBranchBLL; public GetBankBranch(IBankBranchBLL bankBranchBLL) { _BankBranchBLL = bankBranchBLL; } public override void Configure() { Get("/BankBranch/GetBankBranch"); AllowAnonymous(); } public record GetBankBranchParameters( [property: FromHeader] string Login, [property: QueryParam] int BankBranchId ); //protected override string? GetCacheKey(GetBankBranchParameters Parameters, LoginDTO LoginDTO) //{ // try // { // return KeyGenerator.KeyGeneration(Parameters.BankBranchId, EntityConstant.OBJECTBANKBRANCH, CacheKeyLevel.CLIENT_LEVEL, LoginDTO); // } // catch (Exception) // { // throw; // } //} //protected override string? GetCacheKey(GetBankBranchParameters req, LoginDTO login) // => KeyGenerator.KeyGeneration(req.BankBranchId, EntityConstant.OBJECTBANKBRANCH, CacheKeyLevel.USER_LEVEL, login); protected override async Task> ExecuteAsync(GetBankBranchParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _BankBranchBLL.GetBankBranch(req.BankBranchId, LoginDTO!); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(Result, CacheKeyLevel.CLIENT_LEVEL, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.CLIENT_LEVEL, LoginDTO, ex.Message, 500); } } } }