Exemple #1
0
        public ArtistPagedList FilterArtists(ArtistPagedList pagedArtists)
        {
            IList<Artist> filteredArtists = pagedArtists.Artists.Where(artist => !searchArtistRules.Any(s => s.IsArtistRestricted(artist))).ToList();

            pagedArtists.Artists = filteredArtists;
            pagedArtists.Total = pagedArtists.Artists.Count();
            return pagedArtists;
        }
Exemple #2
0
        public SearchResults SearchAll(string searchTerm, string user)
        {
            Login();
            using (var search = session.Search(searchTerm, 0, 30, 0, 15, 0, 15, 0, 0, sp_search_type.STANDARD))
            {
                search.WaitForCompletion();
                if (!search.IsComplete)
                {
                    logger.Error("Search for {0} timed out", searchTerm);
                    return null;
                }
                var results = new SearchResults();

                //set up artists
                var pagedArtists = new ArtistPagedList
                {
                    Total = search.TotalArtists,
                    Artists = search.Artists.Select(a => new ArtistMapper().Map(a, this)).ToArray()
                };

                //set up albums
                var pagedAlbums = new AlbumPagedList
                {
                    Total = search.TotalAlbums,
                    Albums = search.Albums.Where(a => a.IsAvailable)
                        .Select(a => albumMapper.Map(a, this, true))
                        .ToArray()
                };

                ////set up tracks
                var pagedTracks = new TrackPagedList
                {
                    Total = search.TotalTracks,
                    Tracks = search.Tracks
                        .Select(t => trackMapper.Map(t, this, user, true, true))
                        .Where(t => t.IsAvailable)
                        .ToArray()
                };

                results.PagedArtists = pagedArtists;
                results.PagedAlbums = pagedAlbums;
                results.PagedTracks = pagedTracks;

                return results;
            }
        }