You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Lidarr/NzbDrone.Api/Episodes/EpisodeModule.cs

37 lines
1.0 KiB

using System.Collections.Generic;
using NzbDrone.Api.REST;
using NzbDrone.Core.Tv;
namespace NzbDrone.Api.Episodes
{
public class EpisodeModule : NzbDroneRestModule<EpisodeResource>
{
12 years ago
private readonly IEpisodeService _episodeService;
12 years ago
public EpisodeModule(IEpisodeService episodeService)
: base("/episodes")
{
_episodeService = episodeService;
GetResourceAll = GetEpisodes;
}
private List<EpisodeResource> GetEpisodes()
{
var seriesId = (int?)Request.Query.SeriesId;
var seasonNumber = (int?)Request.Query.SeasonNumber;
if (seriesId == null)
{
throw new BadRequestException("seriesId is missing");
}
if (seasonNumber == null)
{
return ToListResource(() => _episodeService.GetEpisodeBySeries(seriesId.Value));
}
return ToListResource(() => _episodeService.GetEpisodesBySeason(seriesId.Value, seasonNumber.Value));
}
}
}