1
0
Fork 0
mirror of https://github.com/Sonarr/Sonarr synced 2024-12-28 10:48:46 +00:00
Sonarr/NzbDrone.Api/Episodes/EpisodeModule.cs

30 lines
881 B
C#
Raw Normal View History

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
{
2013-04-01 06:22:16 +00:00
private readonly IEpisodeService _episodeService;
2013-03-02 19:13:23 +00:00
2013-04-01 06:22:16 +00:00
public EpisodeModule(IEpisodeService episodeService)
2013-03-02 19:13:23 +00:00
: base("/episodes")
{
_episodeService = episodeService;
Get["/"] = x => GetEpisodesForSeries();
2013-03-02 19:13:23 +00:00
}
private Response GetEpisodesForSeries()
2013-03-02 19:13:23 +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();
}
}
}