mirror of
https://github.com/Radarr/Radarr
synced 2024-12-30 20:05:41 +00:00
4188946395
file name sample uses HTTP GET instead of post
46 lines
No EOL
1.3 KiB
C#
46 lines
No EOL
1.3 KiB
C#
using System.Collections.Generic;
|
|
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 = Update;
|
|
|
|
Post["/pass"] = x => SetSeasonPass();
|
|
}
|
|
|
|
private List<SeasonResource> GetSeasons()
|
|
{
|
|
var seriesId = Request.Query.SeriesId;
|
|
|
|
if (seriesId.HasValue)
|
|
{
|
|
return ToListResource<Season>(() => _seasonService.GetSeasonsBySeries(seriesId));
|
|
}
|
|
|
|
return ToListResource(() => _seasonService.GetAllSeasons());
|
|
}
|
|
|
|
private void Update(SeasonResource seasonResource)
|
|
{
|
|
_seasonService.SetMonitored(seasonResource.SeriesId, seasonResource.SeasonNumber, seasonResource.Monitored);
|
|
}
|
|
|
|
private List<SeasonResource> SetSeasonPass()
|
|
{
|
|
var seriesId = Request.Form.SeriesId;
|
|
var seasonNumber = Request.Form.SeasonNumber;
|
|
|
|
return ToListResource<Season>(() => _seasonService.SetSeasonPass(seriesId, seasonNumber));
|
|
}
|
|
}
|
|
} |