private void NewRate(LatestPriceResultMessage result)
        {
            UiDispatcher.Invoke(() =>
            {
                var e = ExchangeRates.FirstOrDefault(x => x.IsSimilarRequest(result));
                if (e != null)
                {
                    ExchangeRates.Remove(e);
                }
                ExchangeRates.Add(result);

                var exrs = ExchangeRates.OrderBy(x => x.Pair.ToString()).ToList();
                ExchangeRates.Clear();

                foreach (var er in exrs)
                {
                    ExchangeRates.Add(er);
                }

                if (AssetLeft.IsNone() || AssetRight.IsNone() || ConvertLeft == 0)
                {
                    return;
                }

                var ap = new AssetPair(AssetLeft, AssetRight);
                if (!result.Pair.Equals(ap))
                {
                    return;
                }

                _isConverted    = result.IsConverted;
                ResultViewModel = new ExchangeRateResultViewModel(this, result);
                LoadingInfo     = "";
            });
        }
Beispiel #2
0
        void Populate()
        {
            var json = js.Invoke <string>("localStorage.getItem", "fxData");

            if (json != null)
            {
                var rawData = JsonSerializer.Deserialize <RawFxData>(json);
                LastUpdatedDate = rawData.Date;

                ExchangeRates.Clear();
                ExchangeRatesLookup.Clear();
                foreach (var currency in supportedCurrencies)
                {
                    if (rawData.Rates.TryGetValue(currency.Code, out var valueInEur))
                    {
                        var exchangeRate = new ExchangeRate(currency, valueInEur);
                        ExchangeRates.Add(exchangeRate);
                        ExchangeRatesLookup.Add(currency.Code, exchangeRate);
                    }
                }
            }
        }