Fixed: Incorrect api error when calling /api/episode without seriesId queryparam.

fixes #1070
pull/4/head
Taloth Saldono 9 years ago
parent 5cfaed7b26
commit 2f50074123

@ -52,16 +52,16 @@ namespace NzbDrone.Api.EpisodeFiles
private List<EpisodeFileResource> GetEpisodeFiles() private List<EpisodeFileResource> GetEpisodeFiles()
{ {
var seriesId = (int?)Request.Query.SeriesId; if (!Request.Query.SeriesId.HasValue)
if (seriesId == null)
{ {
throw new BadRequestException("seriesId is missing"); 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(); .Select(f => MapToResource(series, f)).ToList();
} }

@ -20,14 +20,14 @@ namespace NzbDrone.Api.Episodes
private List<EpisodeResource> GetEpisodes() private List<EpisodeResource> GetEpisodes()
{ {
var seriesId = (int?)Request.Query.SeriesId; if (!Request.Query.SeriesId.HasValue)
if (seriesId == null)
{ {
throw new BadRequestException("seriesId is missing"); 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; return resources;
} }

@ -18,18 +18,13 @@ namespace NzbDrone.Api.Episodes
private List<RenameEpisodeResource> GetEpisodes() private List<RenameEpisodeResource> GetEpisodes()
{ {
int seriesId; if (!Request.Query.SeriesId.HasValue)
if (Request.Query.SeriesId.HasValue)
{
seriesId = (int)Request.Query.SeriesId;
}
else
{ {
throw new BadRequestException("seriesId is missing"); throw new BadRequestException("seriesId is missing");
} }
var seriesId = (int)Request.Query.SeriesId;
if (Request.Query.SeasonNumber.HasValue) if (Request.Query.SeasonNumber.HasValue)
{ {
var seasonNumber = (int)Request.Query.SeasonNumber; var seasonNumber = (int)Request.Query.SeasonNumber;

Loading…
Cancel
Save