public decimal GetExchangeRate(CurrencyPair currencyPair) { if (currencyPair.HaveSameCurrency()) { return(1); } return(_exchangeRateProvider.GetExchangeRate(currencyPair.FromCurrency, currencyPair.ToCurrency)); }
public decimal Convert(decimal amount, CurrencyPair currencyPair) { if (currencyPair.HaveSameCurrency()) { return(amount); } if (amount != 0) { var exchangeRate = GetExchangeRate(currencyPair); return(amount * exchangeRate); } return(amount); }