private async Task ApplySearch() { if (string.IsNullOrWhiteSpace(txtSearchCriteria.Text)) { return; } txtSearchCriteria.IsEnabled = false; if (cmbSearchField.SelectedIndex == 0) //Search ISBN { await googleSearch.Search(GoogleBooksApi.SearchFields.ISBN, txtSearchCriteria.Text.Trim()); lvwLocal.ItemsSource = await _db.AddCatalogIncludes(_db.QueryBooksByIdentifier(txtSearchCriteria.Text.Trim())).ToListAsync(); } else // Search Title { await googleSearch.Search(GoogleBooksApi.SearchFields.InTitle, txtSearchCriteria.Text.Trim()); lvwLocal.ItemsSource = await _db.AddCatalogIncludes(_db.QueryBooksByTitle(txtSearchCriteria.Text.Trim())).ToListAsync(); } if (lvwLocal.Items.Count > 0) { tbiLocal.IsSelected = true; lvwLocal.SelectedValue = lvwLocal.Items[0]; lvwLocal.Focus(); } else if (googleSearch.Client.Items.Count > 0) { tbiGoogle.IsSelected = true; googleSearch.Focus(); } else { StartManualEntry(); } txtSearchCriteria.IsEnabled = true; }