using AccountsBLL.Instrument; 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.Instrument { public class GetInstrument : BaseEndpoint { private readonly IInstrumentBLL _InstrumentBLL; public GetInstrument(IInstrumentBLL InstrumentBLL) { _InstrumentBLL = InstrumentBLL; } public override void Configure() { Get("/Instrument/GetInstrument"); AllowAnonymous(); } public record GetInstrumentParameters( [property: QueryParam] int InstrumentId, [property: FromHeader] string Login ); //protected override string? GetCacheKey(GetInstrumentParameters GetInstrumentParameters, LoginDTO LoginDTO) //{ // try // { // return KeyGenerator.KeyGeneration(GetInstrumentParameters.InstrumentId!, EntityConstant.OBJECTINSTRUMENT, CacheKeyLevel.USER_LEVEL, LoginDTO); // } // catch (Exception) // { // throw; // } //} //protected override string? GetCacheKey(GetInstrumentParameters req, LoginDTO login) // => KeyGenerator.KeyGeneration(req.InstrumentId, EntityConstant.OBJECTINSTRUMENT, CacheKeyLevel.USER_LEVEL, login); protected override async Task> ExecuteAsync(GetInstrumentParameters parameters, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _InstrumentBLL.GetInstrument(parameters.InstrumentId, 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); } } } }