private void OnSearch() { DefaultView = CollectionViewSource.GetDefaultView(DefaultView); if (TextVisiblity == Visibility.Visible) { if (SelectedFilter.Equals("Šifri")) { DefaultView.Filter = w => ((Drink)w).SifraPica.ToUpper().Contains(TextSearch.ToUpper()); } else if (SelectedFilter.Equals("Nazivu")) { DefaultView.Filter = w => ((Drink)w).NazivPica.ToUpper().Contains(TextSearch.ToUpper()); } } else if (DigitVisibility == Visibility.Visible) { try { Double kolicina = Double.Parse(NumberSearch); DefaultView.Filter = w => ((Drink)w).AcutelPrice == kolicina; } catch (Exception ex) { Console.WriteLine($"Greska : {ex.Message}"); } } else if (ComboVisiblity == Visibility.Visible) { if (SelectedFilter.Equals("Tipu")) { DefaultView.Filter = w => ((Drink)w).TipPica.ToString().Contains(SelectedEnum); } else { DefaultView.Filter = w => ((Drink)w).Poreklo.ToString().Contains(SelectedEnum); } } DefaultView.Refresh(); }
private void Search() { CurrentSongs.Clear(); CurrentSongs = new ObservableCollection <ENTITIES.Song>(oServicio.GetCompleteSongs()); switch (SelectedEnumTypeSearch) { case MUSIC.ENTITIES.TypesSeach.Titulo: if (TextSearch != string.Empty) { CurrentSongs = new ObservableCollection <ENTITIES.Song>(CurrentSongs.Where(source => source.Source.ToUpper().Contains(TextSearch.ToUpper())).ToList <ENTITIES.Song>()); } break; case MUSIC.ENTITIES.TypesSeach.Autor: if (TextSearch != string.Empty) { CurrentSongs = new ObservableCollection <ENTITIES.Song>(CurrentSongs.Where(source => source.Autor.ToUpper().Contains(TextSearch.ToUpper())).ToList <ENTITIES.Song>()); } break; case MUSIC.ENTITIES.TypesSeach.Album: if (TextSearch != string.Empty) { CurrentSongs = new ObservableCollection <ENTITIES.Song>(CurrentSongs.Where(source => source.Album.Name.ToUpper().Contains(TextSearch.ToUpper())).ToList <ENTITIES.Song>()); } break; case MUSIC.ENTITIES.TypesSeach.Todos: TextSearch = string.Empty; CurrentSongs = new ObservableCollection <ENTITIES.Song>(oServicio.GetCompleteSongs()); break; } SetConfigurationView(); }