public List <CurrencyRate> GetCurrencyRates(string fromCurrency, float amount)
        {
            List <CurrencyRate> currencyRates = new List <CurrencyRate>();
            float fromRate = EuroCurrencyRates.Find(cr => cr.Name == fromCurrency).Rate;

            if (fromRate == 0)
            {
                return(null);
            }

            string toCurrency;
            float  toRate;

            for (int i = 0; i < 33; i++)
            {
                toCurrency = EuroCurrencyRates[i].Name;
                toRate     = EuroCurrencyRates.Find(cr => cr.Name == toCurrency).Rate;
                currencyRates.Add(new CurrencyRate(toCurrency, toRate / fromRate * amount));
            }
            return(currencyRates);
        }
        public float GetExchangeRateFromDatabase(string from, string to, float amount = 1)
        {
            if (to == null)
            {
                return(0);
            }

            // Convert Euro to Euro
            if (from.ToLower() == to.ToLower())
            {
                return(amount);
            }

            try
            {
                // First Get the exchange rate of both currencies in euro
                float fromRate = EuroCurrencyRates.Find(cr => cr.Name == from).Rate;
                float toRate   = EuroCurrencyRates.Find(cr => cr.Name == to).Rate;

                // Convert Between Euro to Other Currency
                if (from.ToLower() == "eur")
                {
                    return(amount * toRate);
                }
                else if (to.ToLower() == "eur")
                {
                    return(amount / fromRate);
                }
                else
                {
                    // Calculate non EURO exchange rates From A to B
                    return((amount * toRate) / fromRate);
                }
            }
            catch { return(0); }
        }
 private float calculateRate(string currency)
 => EuroCurrencyRates.Find(cr => cr.Name == currency).Rate;