private void SearchGenres(string searchQuery) { QueryGenres.Clear(); foreach (var item in AllGenres) { if (item.GenreName.ToLower().Contains(searchQuery.ToLower())) { QueryGenres.Add(item); } } }
private async Task LoadArtistsAndGenres() { var allArtistsReturned = await _artistService.Get <List <Model.Artist> >(null); var allGenres = await _genreService.Get <List <Model.Genre> >(null); var allArtistGenre = await _artistGenreService.Get <List <Model.ArtistGenre> >(null); foreach (var item in allArtistsReturned) { var genres = allArtistGenre.Where(a => a.ArtistId == item.ArtistId).ToList(); string genresStr = "Genres: "; foreach (var x in genres) { genresStr += allGenres.Where(a => a.GenreId == x.GenreId).Select(a => a.GenreName).FirstOrDefault(); if (x != genres.ElementAt(genres.Count - 1)) { genresStr += ", "; } } AllArtists.Add(new ArtistHelperVM() { ArtistGenresInString = genresStr, ArtistId = item.ArtistId, ArtistMembers = item.ArtistMembers, ArtistName = item.ArtistName, ArtistPhoto = item.ArtistPhoto }); QueryArtists.Add(new ArtistHelperVM() { ArtistGenresInString = genresStr, ArtistId = item.ArtistId, ArtistMembers = item.ArtistMembers, ArtistName = item.ArtistName, ArtistPhoto = item.ArtistPhoto }); } foreach (var item in allGenres) { AllGenres.Add(item); QueryGenres.Add(item); } }