Esempio n. 1
0
        private PagingResource <HistoryResource> GetHistory(PagingResource <HistoryResource> pagingResource)
        {
            var pagingSpec    = pagingResource.MapToPagingSpec <HistoryResource, NzbDrone.Core.History.History>("date", SortDirection.Descending);
            var includeArtist = Request.GetBooleanQueryParameter("includeArtist");
            var includeAlbum  = Request.GetBooleanQueryParameter("includeAlbum");
            var includeTrack  = Request.GetBooleanQueryParameter("includeTrack");

            var eventTypeFilter = pagingResource.Filters.FirstOrDefault(f => f.Key == "eventType");
            var albumIdFilter   = pagingResource.Filters.FirstOrDefault(f => f.Key == "albumId");

            if (eventTypeFilter != null)
            {
                var filterValue = (HistoryEventType)Convert.ToInt32(eventTypeFilter.Value);
                pagingSpec.FilterExpressions.Add(v => v.EventType == filterValue);
            }

            if (albumIdFilter != null)
            {
                var albumId = Convert.ToInt32(albumIdFilter.Value);
                pagingSpec.FilterExpressions.Add(h => h.AlbumId == albumId);
            }


            return(ApplyToPage(_historyService.Paged, pagingSpec, h => MapToResource(h, includeArtist, includeAlbum, includeTrack)));
        }
Esempio n. 2
0
        private PagingResource <HistoryResource> GetHistory(PagingResource <HistoryResource> pagingResource)
        {
            var pagingSpec    = pagingResource.MapToPagingSpec <HistoryResource, NzbDrone.Core.History.History>("date", SortDirection.Descending);
            var includeAuthor = Request.GetBooleanQueryParameter("includeAuthor");
            var includeBook   = Request.GetBooleanQueryParameter("includeBook");

            var eventTypeFilter  = pagingResource.Filters.FirstOrDefault(f => f.Key == "eventType");
            var bookIdFilter     = pagingResource.Filters.FirstOrDefault(f => f.Key == "bookId");
            var downloadIdFilter = pagingResource.Filters.FirstOrDefault(f => f.Key == "downloadId");

            if (eventTypeFilter != null)
            {
                var filterValue = (HistoryEventType)Convert.ToInt32(eventTypeFilter.Value);
                pagingSpec.FilterExpressions.Add(v => v.EventType == filterValue);
            }

            if (bookIdFilter != null)
            {
                var bookId = Convert.ToInt32(bookIdFilter.Value);
                pagingSpec.FilterExpressions.Add(h => h.BookId == bookId);
            }

            if (downloadIdFilter != null)
            {
                var downloadId = downloadIdFilter.Value;
                pagingSpec.FilterExpressions.Add(h => h.DownloadId == downloadId);
            }

            return(ApplyToPage(_historyService.Paged, pagingSpec, h => MapToResource(h, includeAuthor, includeBook)));
        }
Esempio n. 3
0
        private PagingResource<HistoryResource> GetHistory(PagingResource<HistoryResource> pagingResource)
        {
            var pagingSpec = pagingResource.MapToPagingSpec<HistoryResource, EpisodeHistory>("date", SortDirection.Descending);
            var includeSeries = Request.GetBooleanQueryParameter("includeSeries");
            var includeEpisode = Request.GetBooleanQueryParameter("includeEpisode");

            var eventTypeFilter = pagingResource.Filters.FirstOrDefault(f => f.Key == "eventType");
            var episodeIdFilter = pagingResource.Filters.FirstOrDefault(f => f.Key == "episodeId");
            var downloadIdFilter = pagingResource.Filters.FirstOrDefault(f => f.Key == "downloadId");

            if (eventTypeFilter != null)
            {
                var filterValue = (EpisodeHistoryEventType)Convert.ToInt32(eventTypeFilter.Value);
                pagingSpec.FilterExpressions.Add(v => v.EventType == filterValue);
            }

            if (episodeIdFilter != null)
            {
                var episodeId = Convert.ToInt32(episodeIdFilter.Value);
                pagingSpec.FilterExpressions.Add(h => h.EpisodeId == episodeId);
            }

            if (downloadIdFilter != null)
            {
                var downloadId = downloadIdFilter.Value;
                pagingSpec.FilterExpressions.Add(h => h.DownloadId == downloadId);
            }

            return ApplyToPage(_historyService.Paged, pagingSpec, h => MapToResource(h, includeSeries, includeEpisode));
        }
Esempio n. 4
0
        private PagingResource <MovieResource> GetMoviePaged(PagingResource <MovieResource> pagingResource)
        {
            var pagingSpec = pagingResource.MapToPagingSpec <MovieResource, Core.Tv.Movie>();

            pagingSpec.FilterExpression = _moviesService.ConstructFilterExpression(pagingResource.FilterKey, pagingResource.FilterValue, pagingResource.FilterType);

            return(ApplyToPage(_moviesService.Paged, pagingSpec, MapToResource));
        }
Esempio n. 5
0
        private PagingResource <QueueResource> GetQueue(PagingResource <QueueResource> pagingResource)
        {
            var pagingSpec = pagingResource.MapToPagingSpec <QueueResource, NzbDrone.Core.Queue.Queue>("timeleft", SortDirection.Ascending);
            var includeUnknownMovieItems = Request.GetBooleanQueryParameter("includeUnknownMovieItems");
            var includeMovie             = Request.GetBooleanQueryParameter("includeMovie");

            return(ApplyToPage((spec) => GetQueue(spec, includeUnknownMovieItems), pagingSpec, (q) => MapToResource(q, includeMovie)));
        }
Esempio n. 6
0
        private PagingResource <MovieResource> GetCutoffUnmetMovies(PagingResource <MovieResource> pagingResource)
        {
            var pagingSpec = pagingResource.MapToPagingSpec <MovieResource, Core.Movies.Movie>("title", SortDirection.Ascending);

            pagingSpec.FilterExpression = _movieService.ConstructFilterExpression(pagingResource.FilterKey, pagingResource.FilterValue);

            var resource = ApplyToPage(_movieCutoffService.MoviesWhereCutoffUnmet, pagingSpec, v => MapToResource(v, true));

            return(resource);
        }
Esempio n. 7
0
        private PagingResource <MovieResource> GetMissingMovies(PagingResource <MovieResource> pagingResource)
        {
            var pagingSpec = pagingResource.MapToPagingSpec <MovieResource, Core.Tv.Movie>("title", SortDirection.Descending);

            pagingSpec.FilterExpression = _movieService.ConstructFilterExpression(pagingResource.FilterKey, pagingResource.FilterValue);

            var resource = ApplyToPage(_movieService.MoviesWithoutFiles, pagingSpec, v => MapToResource(v, true));

            return(resource);
        }
Esempio n. 8
0
        private PagingResource <LogResource> GetLogs(PagingResource <LogResource> pagingResource)
        {
            var pageSpec = pagingResource.MapToPagingSpec <LogResource, Log>();

            if (pageSpec.SortKey == "time")
            {
                pageSpec.SortKey = "id";
            }

            var levelFilter = pagingResource.Filters.FirstOrDefault(f => f.Key == "level");

            if (levelFilter != null)
            {
                switch (levelFilter.Value)
                {
                case "fatal":
                    pageSpec.FilterExpressions.Add(h => h.Level == "Fatal");
                    break;

                case "error":
                    pageSpec.FilterExpressions.Add(h => h.Level == "Fatal" || h.Level == "Error");
                    break;

                case "warn":
                    pageSpec.FilterExpressions.Add(h => h.Level == "Fatal" || h.Level == "Error" || h.Level == "Warn");
                    break;

                case "info":
                    pageSpec.FilterExpressions.Add(h => h.Level == "Fatal" || h.Level == "Error" || h.Level == "Warn" || h.Level == "Info");
                    break;

                case "debug":
                    pageSpec.FilterExpressions.Add(h => h.Level == "Fatal" || h.Level == "Error" || h.Level == "Warn" || h.Level == "Info" || h.Level == "Debug");
                    break;

                case "trace":
                    pageSpec.FilterExpressions.Add(h => h.Level == "Fatal" || h.Level == "Error" || h.Level == "Warn" || h.Level == "Info" || h.Level == "Debug" || h.Level == "Trace");
                    break;
                }
            }

            var response = ApplyToPage(_logService.Paged, pageSpec, LogResourceMapper.ToResource);

            if (pageSpec.SortKey == "id")
            {
                response.SortKey = "time";
            }

            return(response);
        }
Esempio n. 9
0
        private PagingResource <EpisodeResource> GetCutoffUnmetEpisodes(PagingResource <EpisodeResource> pagingResource)
        {
            var pagingSpec = pagingResource.MapToPagingSpec <EpisodeResource, Episode>("airDateUtc", SortDirection.Descending);

            if (pagingResource.FilterKey == "monitored" && pagingResource.FilterValue == "false")
            {
                pagingSpec.FilterExpression = v => v.Monitored == false || v.Series.Monitored == false;
            }
            else
            {
                pagingSpec.FilterExpression = v => v.Monitored == true && v.Series.Monitored == true;
            }

            var resource = ApplyToPage(_episodeCutoffService.EpisodesWhereCutoffUnmet, pagingSpec, v => MapToResource(v, true, true));

            return(resource);
        }
Esempio n. 10
0
        private PagingResource<EpisodeResource> GetCutoffUnmetEpisodes(PagingResource<EpisodeResource> pagingResource)
        {
            var pagingSpec = pagingResource.MapToPagingSpec<EpisodeResource, Episode>("airDateUtc", SortDirection.Descending);

            if (pagingResource.FilterKey == "monitored" && pagingResource.FilterValue == "false")
            {
                pagingSpec.FilterExpression = v => v.Monitored == false || v.Series.Monitored == false;
            }
            else
            {
                pagingSpec.FilterExpression = v => v.Monitored == true && v.Series.Monitored == true;
            }

            var resource = ApplyToPage(_episodeCutoffService.EpisodesWhereCutoffUnmet, pagingSpec, v => MapToResource(v, true, true));

            return resource;
        }
Esempio n. 11
0
        private PagingResource <EpisodeResource> GetCutoffUnmetEpisodes(PagingResource <EpisodeResource> pagingResource)
        {
            var pagingSpec = pagingResource.MapToPagingSpec <EpisodeResource, Episode>("airDateUtc", SortDirection.Descending);
            var filter     = pagingResource.Filters.FirstOrDefault(f => f.Key == "monitored");

            if (filter != null && filter.Value == "false")
            {
                pagingSpec.FilterExpressions.Add(v => v.Monitored == false || v.Series.Monitored == false);
            }
            else
            {
                pagingSpec.FilterExpressions.Add(v => v.Monitored == true && v.Series.Monitored == true);
            }

            var resource = ApplyToPage(_episodeCutoffService.EpisodesWhereCutoffUnmet, pagingSpec, v => MapToResource(v, true, true));

            return(resource);
        }
Esempio n. 12
0
        private PagingResource <MovieResource> GetMissingMovies(PagingResource <MovieResource> pagingResource)
        {
            var pagingSpec      = pagingResource.MapToPagingSpec <MovieResource, Movie>("title", SortDirection.Descending);
            var monitoredFilter = pagingResource.Filters.FirstOrDefault(f => f.Key == "monitored");

            if (monitoredFilter != null && monitoredFilter.Value == "false")
            {
                pagingSpec.FilterExpressions.Add(v => v.Monitored == false);
            }
            else
            {
                pagingSpec.FilterExpressions.Add(v => v.Monitored == true);
            }

            var resource = ApplyToPage(_movieService.MoviesWithoutFiles, pagingSpec, v => MapToResource(v));

            return(resource);
        }
Esempio n. 13
0
        private PagingResource <LogResource> GetLogs(PagingResource <LogResource> pagingResource)
        {
            var pageSpec = pagingResource.MapToPagingSpec <LogResource, Log>();

            if (pageSpec.SortKey == "time")
            {
                pageSpec.SortKey = "id";
            }

            var filter = pagingResource.Filters.FirstOrDefault();

            if (filter != null && filter.Key == "level")
            {
                switch (filter.Value)
                {
                case "Fatal":
                    pageSpec.FilterExpressions.Add(h => h.Level == "Fatal");
                    break;

                case "Error":
                    pageSpec.FilterExpressions.Add(h => h.Level == "Fatal" || h.Level == "Error");
                    break;

                case "Warn":
                    pageSpec.FilterExpressions.Add(h => h.Level == "Fatal" || h.Level == "Error" || h.Level == "Warn");
                    break;

                case "Info":
                    pageSpec.FilterExpressions.Add(h => h.Level == "Fatal" || h.Level == "Error" || h.Level == "Warn" || h.Level == "Info");
                    break;

                case "Debug":
                    pageSpec.FilterExpressions.Add(h => h.Level == "Fatal" || h.Level == "Error" || h.Level == "Warn" || h.Level == "Info" || h.Level == "Debug");
                    break;

                case "Trace":
                    pageSpec.FilterExpressions.Add(h => h.Level == "Fatal" || h.Level == "Error" || h.Level == "Warn" || h.Level == "Info" || h.Level == "Debug" || h.Level == "Trace");
                    break;
                }
            }

            return(ApplyToPage(_logService.Paged, pageSpec, LogResourceMapper.ToResource));
        }
Esempio n. 14
0
        private PagingResource <EpisodeResource> GetMissingEpisodes(PagingResource <EpisodeResource> pagingResource)
        {
            var pagingSpec      = pagingResource.MapToPagingSpec <EpisodeResource, Episode>("airDateUtc", SortDirection.Descending);
            var includeSeries   = Request.GetBooleanQueryParameter("includeSeries");
            var includeImages   = Request.GetBooleanQueryParameter("includeImages");
            var monitoredFilter = pagingResource.Filters.FirstOrDefault(f => f.Key == "monitored");

            if (monitoredFilter != null && monitoredFilter.Value == "false")
            {
                pagingSpec.FilterExpressions.Add(v => v.Monitored == false || v.Series.Monitored == false);
            }
            else
            {
                pagingSpec.FilterExpressions.Add(v => v.Monitored == true && v.Series.Monitored == true);
            }

            var resource = ApplyToPage(_episodeService.EpisodesWithoutFiles, pagingSpec, v => MapToResource(v, includeSeries, false, includeImages));

            return(resource);
        }
Esempio n. 15
0
        private PagingResource <HistoryResource> GetHistory(PagingResource <HistoryResource> pagingResource)
        {
            var movieId = Request.Query.MovieId;

            var pagingSpec = pagingResource.MapToPagingSpec <HistoryResource, Core.History.History>("date", SortDirection.Descending);

            if (pagingResource.FilterKey == "eventType")
            {
                var filterValue = (HistoryEventType)Convert.ToInt32(pagingResource.FilterValue);
                pagingSpec.FilterExpression = v => v.EventType == filterValue;
            }

            if (movieId.HasValue)
            {
                int i = (int)movieId;
                pagingSpec.FilterExpression = h => h.MovieId == i;
            }

            return(ApplyToPage(_historyService.Paged, pagingSpec, MapToResource));
        }
Esempio n. 16
0
        private PagingResource <HistoryResource> GetHistory(PagingResource <HistoryResource> pagingResource)
        {
            var episodeId  = Request.Query.EpisodeId;
            var pagingSpec = pagingResource.MapToPagingSpec <HistoryResource, Core.History.History>("date", SortDirection.Descending);
            var filter     = pagingResource.Filters.FirstOrDefault();

            if (filter != null && filter.Key == "eventType")
            {
                var filterValue = (HistoryEventType)Convert.ToInt32(filter.Value);
                pagingSpec.FilterExpressions.Add(v => v.EventType == filterValue);
            }

            if (episodeId.HasValue)
            {
                int i = (int)episodeId;
                pagingSpec.FilterExpressions.Add(h => h.EpisodeId == i);
            }

            return(ApplyToPage(_historyService.Paged, pagingSpec, MapToResource));
        }
Esempio n. 17
0
        private PagingResource <LogResource> GetLogs(PagingResource <LogResource> pagingResource)
        {
            var pageSpec = pagingResource.MapToPagingSpec <LogResource, Log>();

            if (pageSpec.SortKey == "time")
            {
                pageSpec.SortKey = "id";
            }

            if (pagingResource.FilterKey == "level")
            {
                switch (pagingResource.FilterValue)
                {
                case "Fatal":
                    pageSpec.FilterExpression = h => h.Level == "Fatal";
                    break;

                case "Error":
                    pageSpec.FilterExpression = h => h.Level == "Fatal" || h.Level == "Error";
                    break;

                case "Warn":
                    pageSpec.FilterExpression = h => h.Level == "Fatal" || h.Level == "Error" || h.Level == "Warn";
                    break;

                case "Info":
                    pageSpec.FilterExpression = h => h.Level == "Fatal" || h.Level == "Error" || h.Level == "Warn" || h.Level == "Info";
                    break;

                case "Debug":
                    pageSpec.FilterExpression = h => h.Level == "Fatal" || h.Level == "Error" || h.Level == "Warn" || h.Level == "Info" || h.Level == "Debug";
                    break;

                case "Trace":
                    pageSpec.FilterExpression = h => h.Level == "Fatal" || h.Level == "Error" || h.Level == "Warn" || h.Level == "Info" || h.Level == "Debug" || h.Level == "Trace";
                    break;
                }
            }

            return(ApplyToPage(_logService.Paged, pageSpec, LogResourceMapper.ToResource));
        }
Esempio n. 18
0
        private PagingResource <BlacklistResource> GetBlacklist(PagingResource <BlacklistResource> pagingResource)
        {
            var pagingSpec = pagingResource.MapToPagingSpec <BlacklistResource, NzbDrone.Core.Blacklisting.Blacklist>("date", SortDirection.Descending);

            return(ApplyToPage(_blacklistService.Paged, pagingSpec, (blacklist) => BlacklistResourceMapper.MapToResource(blacklist, _formatCalculator)));
        }
Esempio n. 19
0
        private PagingResource <BlocklistResource> Blocklist(PagingResource <BlocklistResource> pagingResource)
        {
            var pagingSpec = pagingResource.MapToPagingSpec <BlocklistResource, NzbDrone.Core.Blocklisting.Blocklist>("date", SortDirection.Descending);

            return(ApplyToPage(_blocklistService.Paged, pagingSpec, BlocklistResourceMapper.MapToResource));
        }
Esempio n. 20
0
        private PagingResource <BlacklistResource> GetBlacklist(PagingResource <BlacklistResource> pagingResource)
        {
            var pagingSpec = pagingResource.MapToPagingSpec <BlacklistResource, Core.Blacklisting.Blacklist>("id", SortDirection.Ascending);

            return(ApplyToPage(_blacklistService.Paged, pagingSpec, BlacklistResourceMapper.MapToResource));
        }