From 2f50074123dd9def92ef14ba626a56693e16d7bc Mon Sep 17 00:00:00 2001 From: Taloth Saldono Date: Wed, 20 Jan 2016 21:49:54 +0100 Subject: [PATCH] Fixed: Incorrect api error when calling /api/episode without seriesId queryparam. fixes #1070 --- src/NzbDrone.Api/EpisodeFiles/EpisodeFileModule.cs | 10 +++++----- src/NzbDrone.Api/Episodes/EpisodeModule.cs | 8 ++++---- src/NzbDrone.Api/Episodes/RenameEpisodeModule.cs | 11 +++-------- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/src/NzbDrone.Api/EpisodeFiles/EpisodeFileModule.cs b/src/NzbDrone.Api/EpisodeFiles/EpisodeFileModule.cs index 874f3aaa3..2981e96e4 100644 --- a/src/NzbDrone.Api/EpisodeFiles/EpisodeFileModule.cs +++ b/src/NzbDrone.Api/EpisodeFiles/EpisodeFileModule.cs @@ -52,16 +52,16 @@ namespace NzbDrone.Api.EpisodeFiles private List GetEpisodeFiles() { - var seriesId = (int?)Request.Query.SeriesId; - - if (seriesId == null) + if (!Request.Query.SeriesId.HasValue) { throw new BadRequestException("seriesId is missing"); } - var series = _seriesService.GetSeries(seriesId.Value); + var seriesId = (int)Request.Query.SeriesId; + + var series = _seriesService.GetSeries(seriesId); - return _mediaFileService.GetFilesBySeries(seriesId.Value) + return _mediaFileService.GetFilesBySeries(seriesId) .Select(f => MapToResource(series, f)).ToList(); } diff --git a/src/NzbDrone.Api/Episodes/EpisodeModule.cs b/src/NzbDrone.Api/Episodes/EpisodeModule.cs index a14cfa2f3..4535e4191 100644 --- a/src/NzbDrone.Api/Episodes/EpisodeModule.cs +++ b/src/NzbDrone.Api/Episodes/EpisodeModule.cs @@ -20,14 +20,14 @@ namespace NzbDrone.Api.Episodes private List GetEpisodes() { - var seriesId = (int?)Request.Query.SeriesId; - - if (seriesId == null) + if (!Request.Query.SeriesId.HasValue) { throw new BadRequestException("seriesId is missing"); } - var resources = ToListResource(_episodeService.GetEpisodeBySeries(seriesId.Value)); + var seriesId = (int)Request.Query.SeriesId; + + var resources = ToListResource(_episodeService.GetEpisodeBySeries(seriesId)); return resources; } diff --git a/src/NzbDrone.Api/Episodes/RenameEpisodeModule.cs b/src/NzbDrone.Api/Episodes/RenameEpisodeModule.cs index ffe9a37e0..e35c3f93e 100644 --- a/src/NzbDrone.Api/Episodes/RenameEpisodeModule.cs +++ b/src/NzbDrone.Api/Episodes/RenameEpisodeModule.cs @@ -18,18 +18,13 @@ namespace NzbDrone.Api.Episodes private List GetEpisodes() { - int seriesId; - - if (Request.Query.SeriesId.HasValue) - { - seriesId = (int)Request.Query.SeriesId; - } - - else + if (!Request.Query.SeriesId.HasValue) { throw new BadRequestException("seriesId is missing"); } + var seriesId = (int)Request.Query.SeriesId; + if (Request.Query.SeasonNumber.HasValue) { var seasonNumber = (int)Request.Query.SeasonNumber;