using AccountsBLL.AccountGroup; using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace AccountsSL.EndPoints.AccountGroup { public class GetAccountGroup : BaseEndpoint> { private readonly IAccountGroupBLL _AccountGroupBLL; public GetAccountGroup(IAccountGroupBLL accountGroupBLL) => _AccountGroupBLL = accountGroupBLL; public override void Configure() { Get("/AccountGroup/GetAccountGroup"); AllowAnonymous(); } public record GetAccountGroupParameters( [property: FromHeader] string Login, [property: QueryParam] int AccountGroupId ); //protected override string? GetCacheKey(GetAccountGroupParameters req, LoginDTO login) // => KeyGenerator.KeyGeneration(req.AccountGroupId, EntityConstant.OBJECTACCOUNTGROUP, CacheKeyLevel.USER_LEVEL, login); protected override async Task> ExecuteAsync( GetAccountGroupParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _AccountGroupBLL.GetAccountGroup(req.AccountGroupId, 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); } } } }