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