Esempio n. 1
0
        async Task ExecuteLoadCurrenciesCommand()
        {
            if (this.IsBusy)
            {
                return;
            }

            this.IsBusy = true;

            try
            {
                this.Currencies.Clear();
                var fixer   = new FixerDataStore();
                var symbols = await fixer.GetAllCurrencySymbols();

                var rates = await fixer.GetLatestCurrencyExchange();

                if (symbols.IsSuccessful() && rates.IsSuccessful())
                {
                    var fsymbols = (Symbols)symbols;
                    var frates   = (Currency)rates;
                    foreach (var symbol in fsymbols.SymbolDictionary)
                    {
                        this.Currencies.Add(new CompleteCurrency
                        {
                            Code = symbol.Key,
                            Name = symbol.Value,
                            Rate = (double)frates.Rates[symbol.Key]
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                this.IsBusy = false;
            }
        }
 public void SetUp() => this.fixerDataStore = new FixerDataStore();