2013-07-09 15:41:42 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2013-03-03 22:26:41 +00:00
|
|
|
|
using Nancy;
|
|
|
|
|
using NzbDrone.Api.Extensions;
|
2013-07-09 15:41:42 +00:00
|
|
|
|
using NzbDrone.Api.REST;
|
2013-03-03 22:26:41 +00:00
|
|
|
|
using NzbDrone.Core.Tv;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Api.Seasons
|
|
|
|
|
{
|
2013-07-09 15:41:42 +00:00
|
|
|
|
public class SeasonModule : NzbDroneRestModule<SeasonResource>
|
2013-03-03 22:26:41 +00:00
|
|
|
|
{
|
|
|
|
|
private readonly ISeasonService _seasonService;
|
|
|
|
|
|
|
|
|
|
public SeasonModule(ISeasonService seasonService)
|
2013-07-09 15:41:42 +00:00
|
|
|
|
: base("/season")
|
2013-03-03 22:26:41 +00:00
|
|
|
|
{
|
|
|
|
|
_seasonService = seasonService;
|
|
|
|
|
|
2013-07-09 15:41:42 +00:00
|
|
|
|
GetResourceAll = GetSeasons;
|
|
|
|
|
UpdateResource = SetMonitored;
|
2013-03-03 22:26:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-07-09 15:41:42 +00:00
|
|
|
|
private List<SeasonResource> GetSeasons()
|
2013-03-03 22:26:41 +00:00
|
|
|
|
{
|
|
|
|
|
var seriesId = Request.Query.SeriesId;
|
|
|
|
|
|
2013-07-09 15:41:42 +00:00
|
|
|
|
return ToListResource<Season>(() => _seasonService.GetSeasonsBySeries(seriesId));
|
2013-03-03 22:26:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-07-09 15:41:42 +00:00
|
|
|
|
private SeasonResource SetMonitored(SeasonResource seasonResource)
|
|
|
|
|
{
|
|
|
|
|
_seasonService.SetMonitored(seasonResource.SeriesId, seasonResource.SeasonNumber, seasonResource.Monitored);
|
2013-03-03 22:26:41 +00:00
|
|
|
|
|
2013-07-09 15:41:42 +00:00
|
|
|
|
return seasonResource;
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-03-03 22:26:41 +00:00
|
|
|
|
}
|