private void fetch_currency_exchange_rates()
{
bool need_to_fetch = check_currencies_must_be_updated();
if (need_to_fetch)
{
string url = "http://openexchangerates.org/latest.json";
string data = urlread(url);
DateTime time_fetched = DateTime.Now;
JObject j = JsonConvert.DeserializeObject<JObject>(data);
foreach (JProperty rate in j["rates"])
{
string code = rate.Name;
double rate_value = Convert.ToDouble(rate.Value.ToString());
if (!(exchange_rates.Keys.Contains(code)))
{
exchange_rates[code] = new exchange_rate();
}
exchange_rates[code].rate = rate_value;
exchange_rates[code].time_fetched = time_fetched;
}
save_exchange_rates_in_settings();
}
}