internal decimal Exchange(decimal amount, ExchangeDirection direction) { var rate = direction == ExchangeDirection.RateIn ? this.rateIn : this.rateOut; var roundedAmount = Math.Round(amount, this.sourceCurrency.Decimals, MidpointRounding.AwayFromZero); var exchangedValue = roundedAmount * rate; return(Math.Round(exchangedValue, this.targetCurrency.Decimals, MidpointRounding.AwayFromZero)); }
public Rate CreateRate(string rate, string exchangeCode, ExchangeDirection direction) { return(new Rate { CurrencyRate = double.Parse(rate), ExchangeCode = exchangeCode, Direction = direction }); }