public Task Filter() { if (!FilterQuery.IsNullOrEmpty()) { try { if (FilterQuery != _lastFilterQuery) { if (_lastFilterQuery.IsNullOrEmpty()) { _cachedEvents = Events; } _lastFilterQuery = FilterQuery; char[] toTrim = { ' ', '"', '\'' }; var query = FilterQuery.Trim(toTrim); Events = _dbs.GetEvents(query).ToObservableCollection(); } } catch (Newtonsoft.Json.JsonException) { throw new FormatException("Incorrect oauth token file format. Restore or delete it and try again"); } catch (DataException) { throw new DataException("Failed to modify database. Verify the connection and try again"); } } else if (_cachedEvents != null) { Events = _cachedEvents; } return(Task.CompletedTask); }
/// <summary> /// method for filterCommand /// </summary> public void FilterExecute() { FilteredCollection.Clear(); switch (SelectedFilterItem) { case "System.Windows.Controls.ComboBoxItem: Titel": foreach (ViewComic viewComic in _comicList) { if (viewComic.Title.Trim().Contains(FilterQuery.Trim())) { FilteredCollection.Add(new GridRow(viewComic)); } } break; case "System.Windows.Controls.ComboBoxItem: Reeks": foreach (ViewComic viewComic in _comicList) { if (viewComic.Series.Name.Trim().Contains(FilterQuery.Trim())) { FilteredCollection.Add(new GridRow(viewComic)); } } break; case "System.Windows.Controls.ComboBoxItem: Auteur": foreach (ViewComic viewComic in _comicList) { foreach (ViewAuthor author in viewComic.Authors) { if (author.Name.Trim().Contains(FilterQuery.Trim())) { FilteredCollection.Add(new GridRow(viewComic)); } } } break; case "System.Windows.Controls.ComboBoxItem: Uitgeverij": foreach (ViewComic viewComic in _comicList) { if (viewComic.Publisher.Name.Trim().Contains(FilterQuery.Trim())) { FilteredCollection.Add(new GridRow(viewComic)); } } break; default: break; } }