示例#1
0
        public void CalculateQuoteForeignCurrencyTest(int amount, decimal foreignCurrencyConversionRate)
        {
            var exchangeRate = new ExchangeRate(amount, foreignCurrencyConversionRate);
            var calculate    = exchangeRate.CalculateQuoteForeignCurrency();

            Assert.Equal(calculate, (amount * foreignCurrencyConversionRate));
        }
        public async Task <ExchangeRateResponse> GetQuoteForeignCurrencyAsync(QuoteForeignCurrencyRequest request)
        {
            var foreignExchangeRate = await _foreignExchangeRatesService.GetLatestExchangeRateAsync(request.Currency);

            if (foreignExchangeRate == null)
            {
                _domainNotification.AddNotification("QuoteForeignCurrency", "Foreign Exchange Rates API request error");

                return(null);
            }

            var exchangeRate = new ExchangeRate(request.Amount, foreignExchangeRate.Rates.BrazilianReal);
            var calculateQuoteForeignCurrency = exchangeRate.CalculateQuoteForeignCurrency();

            return(new ExchangeRateResponse(calculateQuoteForeignCurrency));
        }