using AccountsBLL.Insurance; using AccountsBLL.Party; 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.Party { public class GetParty : BaseEndpoint> { private readonly IPartyBLL _PartyBLL; public GetParty(IPartyBLL partyBLL) { _PartyBLL = partyBLL; } public override void Configure() { Get("/Party/GetParty"); AllowAnonymous(); } public record GetPartyParameters( [property: FromHeader] string Login, [property: QueryParam] int PartyId ); //protected override string? GetCacheKey(GetPartyParameters Parameters, LoginDTO LoginDTO) //{ // try // { // return KeyGenerator.KeyGeneration(Parameters.PartyId!, EntityConstant.OBJECTPARTY, CacheKeyLevel.USER_LEVEL, LoginDTO); // } // catch (Exception) // { // throw; // } //} // protected override string? GetCacheKey(GetPartyParameters req, LoginDTO login) //=> KeyGenerator.KeyGeneration(req.PartyId, EntityConstant.OBJECTPARTY, CacheKeyLevel.USER_LEVEL, login); protected override async Task> ExecuteAsync(GetPartyParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _PartyBLL.GetParty(req.PartyId, 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); } } } }