protected decimal GetConvertedAmount(decimal amount, CurrencyRateInfo currentCurrencyRateInfo, CurrencyRateInfo targetCurrencyRateInfo) { currentCurrencyRateInfo.CheckArgumentNull(nameof(currentCurrencyRateInfo)); targetCurrencyRateInfo.CheckArgumentNull(nameof(targetCurrencyRateInfo)); ValidateRateAndDivicion(currentCurrencyRateInfo); ValidateRateAndDivicion(targetCurrencyRateInfo); return((amount * currentCurrencyRateInfo.Division * targetCurrencyRateInfo.Rate) / (targetCurrencyRateInfo.Division * currentCurrencyRateInfo.Rate)); }
/// <summary> /// Returns converted amount to currency. /// </summary> /// <param name="currentCurrencyRateInfo">Current currency rate information.</param> /// <param name="targetCurrencyRateInfo">Target currency rate information.</param> /// <param name="amount">Amount.</param> /// <returns>Converted amount.</returns> public decimal GetConvertedAmountToCurrency(CurrencyRateInfo currentCurrencyRateInfo, CurrencyRateInfo targetCurrencyRateInfo, decimal amount) { if (amount == 0) { return(amount); } currentCurrencyRateInfo.CheckArgumentNull(nameof(currentCurrencyRateInfo)); targetCurrencyRateInfo.CheckArgumentNull(nameof(targetCurrencyRateInfo)); decimal convertedValue = GetConvertedAmount(amount, currentCurrencyRateInfo, targetCurrencyRateInfo); return(convertedValue); }