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))); }
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)); }