mirror of
https://github.com/Sonarr/Sonarr
synced 2024-12-26 09:47:39 +00:00
37 lines
No EOL
1 KiB
C#
37 lines
No EOL
1 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Nancy;
|
|
using NzbDrone.Api.Extensions;
|
|
using NzbDrone.Api.REST;
|
|
using NzbDrone.Core.Tv;
|
|
|
|
namespace NzbDrone.Api.Seasons
|
|
{
|
|
public class SeasonModule : NzbDroneRestModule<SeasonResource>
|
|
{
|
|
private readonly ISeasonService _seasonService;
|
|
|
|
public SeasonModule(ISeasonService seasonService)
|
|
: base("/season")
|
|
{
|
|
_seasonService = seasonService;
|
|
|
|
GetResourceAll = GetSeasons;
|
|
UpdateResource = SetMonitored;
|
|
}
|
|
|
|
private List<SeasonResource> GetSeasons()
|
|
{
|
|
var seriesId = Request.Query.SeriesId;
|
|
|
|
return ToListResource<Season>(() => _seasonService.GetSeasonsBySeries(seriesId));
|
|
}
|
|
|
|
private SeasonResource SetMonitored(SeasonResource seasonResource)
|
|
{
|
|
_seasonService.SetMonitored(seasonResource.SeriesId, seasonResource.SeasonNumber, seasonResource.Monitored);
|
|
|
|
return seasonResource;
|
|
}
|
|
}
|
|
} |