public NbRate OfficialRateFromString(string s, IEnumerable <Account> accountsPlaneList) { var rate = new NbRate(); var substrings = s.Split(';'); rate.Date = Convert.ToDateTime(substrings[0], new CultureInfo("ru-RU")); rate.UsdRate = Convert.ToDouble(substrings[1], new CultureInfo("en-US")); rate.EurRate = Convert.ToDouble(substrings[2], new CultureInfo("en-US")); rate.RurRate = Convert.ToDouble(substrings[3], new CultureInfo("en-US")); return(rate); }
private void DownloadRatesFromNbRbSiteForDate(DateTime date) { var dateRates = _nbRbRatesExtractor.GetRatesForDate(date); if (dateRates == null) { MessageBox.Show($"Курсы за {date} недоступны"); return; } Line = new NbRate() { Date = date }; foreach (var rate in dateRates) { switch (rate.Key) { case CurrencyCodes.USD: Line.UsdRate = ConsiderDenominations(date, rate); break; case CurrencyCodes.EUR: Line.EurRate = ConsiderDenominations(date, rate); break; case CurrencyCodes.RUB: Line.RurRate = ConsiderDenominations(date, rate); break; default: MessageBox.Show($"Неизвестная валюта {rate.Key}"); break; } } Execute.OnUIThread(UiThreadWork); }
public string Dump(NbRate rate) { return(Convert.ToString(rate.Date, new CultureInfo("ru-RU")) + " ; " + rate.UsdRate.ToString(new CultureInfo("en-US")) + " ; " + rate.EurRate.ToString(new CultureInfo("en-US")) + " ; " + rate.RurRate.ToString(new CultureInfo("en-US"))); }