public static string GetStringFromFeeType(FeeTypeEnum value) { switch (value) { case FeeTypeEnum.Free: return("免费"); case FeeTypeEnum.LT50: return("50元内"); case FeeTypeEnum.LT100: return("100元内"); case FeeTypeEnum.LT500: return("500元内"); case FeeTypeEnum.LT1000: return("1000元内"); case FeeTypeEnum.NoLimit: return("很多钱"); default: return("免费"); } }
/// <summary> /// 转换成枚举 /// </summary> public static int FeeTypeToValue(FeeTypeEnum enumOption) { try{ return((int)enumOption); }catch (Exception ex) { throw new ArgumentException("enumOption", ex); } }
private static SelectList CreateFeeTypes(FeeTypeEnum SelectedType) { Dictionary <int, string> feeTypes = new Dictionary <int, string>(); foreach (int i in Enum.GetValues(typeof(FeeTypeEnum))) { feeTypes.Add(i, Together.GetStringFromFeeType((FeeTypeEnum)i)); } return(new SelectList(feeTypes, "Key", "Value", (int)SelectedType)); }
private async Task <CalculateFeeCoefficientsOfType> GetCoefficientByType(FeeTypeEnum type) { if (type == FeeTypeEnum.Tx) { return(await TokenContractStub.GetCalculateFeeCoefficientOfSender.CallAsync(new Empty())); } return(await TokenContractStub.GetCalculateFeeCoefficientOfContract.CallAsync(new SInt32Value { Value = (int)type })); }
public async Task Update_Coefficient_For_Contract_Should_Success() { const int pieceKey = 1000000; const FeeTypeEnum feeType = FeeTypeEnum.Traffic; var updateInput = new CoefficientFromContract { FeeType = feeType, Coefficient = new CoefficientFromSender { LinerCoefficient = new LinerCoefficient { ConstantValue = 1, Denominator = 2, Numerator = 3 }, PieceKey = pieceKey, IsLiner = true } }; var proposalId = await CreateToRootForDeveloperFeeByTwoLayer(updateInput); await ApproveToRootForDeveloperFeeByTwoLayer(proposalId); var middleApproveProposalId = await ApproveToRootForDeveloperFeeByMiddleLayer(proposalId); await ApproveThenReleaseMiddleProposalForDeveloper(middleApproveProposalId); await ReleaseToRootForDeveloperFeeByTwoLayer(proposalId); var developerCoefficientRet = await MainChainTester.ExecuteContractWithMiningAsync(TokenContractAddress, nameof(TokenContractContainer.TokenContractStub.GetCalculateFeeCoefficientOfContract), new SInt32Value { Value = (int)feeType }); developerCoefficientRet.Status.ShouldBe(TransactionResultStatus.Mined); var userCoefficient = new CalculateFeeCoefficientsOfType(); userCoefficient.MergeFrom(developerCoefficientRet.ReturnValue); var hasModified = userCoefficient.Coefficients.Single(x => x.PieceKey == pieceKey); hasModified.CoefficientDic["ConstantValue".ToLower()].ShouldBe(1); hasModified.CoefficientDic["Denominator".ToLower()].ShouldBe(2); hasModified.CoefficientDic["Numerator".ToLower()].ShouldBe(3); }