Exemplo n.º 1
0
        public async Task <IActionResult> GetQuotes(string sourceCurrency, string destinationCurrency)
        {
            var destionationCurrencyList = new List <string>()
            {
                destinationCurrency
            };

            try
            {
                QuoteCurrencyResult result = await quoteCurrencyService.GetQuote(sourceCurrency, destionationCurrencyList);

                return(Ok(result));
            }
            catch (Exception exception)
            {
                return(StatusCode(500, exception));
            }
        }
Exemplo n.º 2
0
        private QuoteCurrencyResult ParseCurrencyLayerResult(CurrencyLayerResult currencyLayerResult)
        {
            var result = new QuoteCurrencyResult()
            {
                Quotes = new List <Quote>()
            };

            result.Source = currencyLayerResult.Source;

            foreach (KeyValuePair <string, double> quote in currencyLayerResult.Quotes)
            {
                var currencyName = quote.Key;
                currencyName = currencyName.Replace(result.Source, "");

                result.Quotes.Add(new Quote()
                {
                    CurrencyName  = currencyName,
                    CurrencyValue = quote.Value
                });
            }

            return(result);
        }