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