mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-11 03:52:33 +02:00
44 lines
1.2 KiB
C#
44 lines
1.2 KiB
C#
using System.Collections.Generic;
|
|
using NzbDrone.Api.Mapping;
|
|
using NzbDrone.Api.REST;
|
|
using NzbDrone.Core.Tv;
|
|
|
|
namespace NzbDrone.Api.Episodes
|
|
{
|
|
public class EpisodeModule : NzbDroneRestModule<EpisodeResource>
|
|
{
|
|
private readonly IEpisodeService _episodeService;
|
|
|
|
public EpisodeModule(IEpisodeService episodeService)
|
|
: base("/episodes")
|
|
{
|
|
_episodeService = episodeService;
|
|
|
|
GetResourceAll = GetEpisodes;
|
|
UpdateResource = SetMonitored;
|
|
GetResourceById = GetEpisode;
|
|
}
|
|
|
|
private List<EpisodeResource> GetEpisodes()
|
|
{
|
|
var seriesId = (int?)Request.Query.SeriesId;
|
|
|
|
if (seriesId == null)
|
|
{
|
|
throw new BadRequestException("seriesId is missing");
|
|
}
|
|
|
|
return ToListResource(() => _episodeService.GetEpisodeBySeries(seriesId.Value));
|
|
}
|
|
|
|
private void SetMonitored(EpisodeResource episodeResource)
|
|
{
|
|
_episodeService.SetEpisodeMonitored(episodeResource.Id, episodeResource.Monitored);
|
|
}
|
|
|
|
private EpisodeResource GetEpisode(int id)
|
|
{
|
|
return _episodeService.GetEpisode(id).InjectTo<EpisodeResource>();
|
|
}
|
|
}
|
|
} |