public AddAddressViewModel(WalletService ws, PoolingService ps) { _poolingService = ps; _walletService = ws; Task.Run(() => _walletService.GetAvailabeTickers().ContinueWith((result) => { if (result.Exception == null) { var tickerSelected = new TickerDTO() { CoinSymbol = "Auto Detect", Degraded = false }; Application.Current.Dispatcher.Invoke(() => { TickerList.Add(tickerSelected); foreach (var ticker in result.Result.OrderBy(o => o.CoinSymbol).ToList()) { TickerList.Add(ticker); } NotifyOfPropertyChange(() => TickerList); SelectedTicker = tickerSelected; }); } })); }
// Load stocks the loooong way... // Method has several reasons to change: // 1. What if the service model class (Stock) changes? // 2. What if the service method changes? // 3. What if the logic for adding to the ticker list changes? // 4. What if the logic for adding the My Watch List changes? public async Task LoadStocksEnumerable() { this.IsLoading = true; var stocks = await _Service.GetAllStocks(); foreach (var stock in stocks) { StockViewModel svm = new StockViewModel(stock); TickerList.Add(svm); if (MyWatchListSymbols.Contains(svm.Symbol)) { MyWatchList.Add(svm); } } this.IsLoading = false; }