private void LoadSearchResults() { PerformAction(async() => { try { _isSearchInProgress = true; var stockItems = await _stockBussinessLogic.SearchStockItems(SearchText, _searchPageIndex); if (stockItems != null && stockItems.Count > 0) { if (_searchPageIndex == 1) { StockItems.Clear(); } var tempStockItems = new ObservableCollection <StockModel>(); foreach (var stockItem in stockItems) { tempStockItems.Add(stockItem); } StockItems = new ObservableCollection <StockModel>(StockItems.Concat(tempStockItems)); SelectedStockItem = StockItems.FirstOrDefault(); } } finally { _tracker.Stop(); Log.Info(string.Format("Time taken by stock search is {0}ms", _tracker.Elapsed.TotalMilliseconds)); SearchText = string.Empty; } }, SearchTextFieldName); }
/// <summary> /// Loads all the Stock items /// </summary> private void LoadAllStockItems() { PerformAction(async() => { _isSearchInProgress = false; var stockItems = await _stockBussinessLogic.GetStockItems(_allStockItemsPageIndex); if (stockItems != null && stockItems.Count > 0) { if (_allStockItemsPageIndex == 1) { StockItems.Clear(); } var tempStockItems = new ObservableCollection <StockModel>(); foreach (var stockItem in stockItems) { tempStockItems.Add(stockItem); } StockItems = new ObservableCollection <StockModel>(StockItems.Concat(tempStockItems)); } }, SearchTextFieldName); }