private Task FilterSongs() { Task task = new Task(() => { var keyword = txtSearch.Text.Trim().ToUpper(); if (keyword != "" && !CompareStringHelper.Contanins(keyword, "Nhập tên bài hát, nghệ sĩ")) { Songs = Songs.Where(s => CompareStringHelper.Contanins(s.DisplayName, keyword) || CompareStringHelper.Contanins(s.ArtistsNames, keyword) || CompareStringHelper.Contanins(s.Performer, keyword)).ToList(); } else { Songs = Songs.ToList(); } if (CategoryListActive.Count > 0) { Songs = Songs.Where(s => CategoryListActive.Any(c => c == s.CategorySongID)).ToList(); } }); task.Start(); return(task); }
private Task FilterPlaylistItem() { Task task = new Task(() => { var keyword = txtSearch.Text.Trim().ToUpper(); if (keyword != "" && !CompareStringHelper.Contanins(keyword, "Nhập tên bài hát, nghệ sĩ")) { PlaylistItemUCResult = PlaylistItemUCMockData.Where(p => { var s = p.Tag as Song; return(CompareStringHelper.Contanins(s.DisplayName, keyword) || CompareStringHelper.Contanins(s.ArtistsNames, keyword) || CompareStringHelper.Contanins(s.Performer, keyword)); }).ToList(); } else { PlaylistItemUCResult = PlaylistItemUCMockData.ToList(); } if (CategoryListActive.Count > 0) { PlaylistItemUCResult = PlaylistItemUCResult.Where(p => { var s = p.Tag as Song; return(CategoryListActive.Any(c => c == s.CategorySongID)); }).ToList(); } }); task.Start(); return(task); }
private async Task FilterPlaylistItem() { Task task = new Task(() => { var keyword = txtSearch.Text.Trim().ToUpper(); if (keyword != "" && !CompareStringHelper.Contanins(keyword, "Nhập tên bài hát, nghệ sĩ hoặc MV...")) { PlaylistItemPUCResult = PlaylistItemPUCMockData.Where(p => { var s = p.Tag as Song; return(CompareStringHelper.Contanins(s.DisplayName, keyword) || CompareStringHelper.Contanins(s.ArtistsNames, keyword) || CompareStringHelper.Contanins(s.Performer, keyword)); }).ToList(); } else { PlaylistItemPUCResult = PlaylistItemPUCMockData.ToList(); } if (CategoryListActive.Count > 0) { PlaylistItemPUCResult = PlaylistItemPUCResult.Where(p => { var s = p.Tag as Song; return(CategoryListActive.Any(c => c == s.CategorySongID)); }).ToList(); } // filter by localfile var favoriteSongs = _songPersonalService.GetAll().Select(f => f.ID).ToList(); PlaylistItemPUCResult = PlaylistItemPUCResult.Where(p => favoriteSongs.Contains(p.Song.ID)).ToList(); }); task.Start(); await task; PlaylistItemPUCResult = PlaylistItemPUCResult.OrderBy(p => p.order).ToList(); }