コード例 #1
0
        public async Task <ExchangeResult> GetExchangeRateAsync(ExchangeRateRequest request)
        {
            var result = await _exchangeRetriever.Retrieve(request);

            // TODO: handle currency not found
            return(new ExchangeResult(request.To, _roundCalculator.EnsureRate(result?.Value ?? -1)));
        }
コード例 #2
0
        public async Task <ExchangeResult> ExchangeAsync(ExchangeRateRequest request, decimal amount)
        {
            var initialRate = await GetRate(request);

            var rate         = RoundCalculator.EnsureRate(initialRate);
            var resultAmount = RoundCalculator.EnsureExchange(amount, rate);

            return(new ExchangeResult(request.To, amount));
        }