using AccountsBLL.PartyOU; using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static AccountsSL.EndPoints.CostCenter.GetCostCenter; using static GB5Shared.GB5Constant.Constant; namespace AccountsSL.EndPoints.PartyOU { public class GetPartyOU : BaseEndpoint> { private readonly IPartyOUBLL _PartyOUBLL; public GetPartyOU(IPartyOUBLL partyOUBLL) { _PartyOUBLL = partyOUBLL; } public override void Configure() { Get("/PartyOU/GetPartyOU"); AllowAnonymous(); } public record GetPartyOUParameters( [property: FromHeader] string Login, [property: QueryParam] int PartyOUId ); //protected override string? GetCacheKey(GetPartyOUParameters Parameters, LoginDTO LoginDTO) //{ // try // { // return KeyGenerator.KeyGeneration(Parameters.PartyOUId, EntityConstant.OBJECTPARTYOU, CacheKeyLevel.CLIENT_LEVEL, LoginDTO); // } // catch (Exception) // { // throw; // } //} // protected override string? GetCacheKey(GetPartyOUParameters req, LoginDTO login) //=> KeyGenerator.KeyGeneration(req.PartyOUId, EntityConstant.OBJECTPARTYOU, CacheKeyLevel.USER_LEVEL, login); protected override async Task> ExecuteAsync(GetPartyOUParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _PartyOUBLL.GetPartyOU(req.PartyOUId, 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); } } } }