2013-03-03 23:18:43 +00:00
|
|
|
|
using System.Collections.Generic;
|
2013-03-02 19:13:23 +00:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using AutoMapper;
|
|
|
|
|
using Nancy;
|
|
|
|
|
using NzbDrone.Api.Extensions;
|
|
|
|
|
using NzbDrone.Core.Tv;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Api.Episodes
|
|
|
|
|
{
|
|
|
|
|
public class EpisodeModule : NzbDroneApiModule
|
|
|
|
|
{
|
|
|
|
|
private readonly EpisodeService _episodeService;
|
|
|
|
|
|
|
|
|
|
public EpisodeModule(EpisodeService episodeService)
|
|
|
|
|
: base("/episodes")
|
|
|
|
|
{
|
|
|
|
|
_episodeService = episodeService;
|
2013-03-03 23:18:43 +00:00
|
|
|
|
Get["/"] = x => GetEpisodesForSeries();
|
2013-03-02 19:13:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-03-03 23:18:43 +00:00
|
|
|
|
private Response GetEpisodesForSeries()
|
2013-03-02 19:13:23 +00:00
|
|
|
|
{
|
2013-03-03 23:18:43 +00:00
|
|
|
|
var seriesId = (int)Request.Query.SeriesId;
|
|
|
|
|
var seasonNumber = (int)Request.Query.SeasonNumber;
|
|
|
|
|
|
|
|
|
|
var episodes = _episodeService.GetEpisodesBySeason(seriesId, seasonNumber);
|
2013-03-02 19:13:23 +00:00
|
|
|
|
return Mapper.Map<List<Episode>, List<EpisodeResource>>(episodes).AsResponse();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|