mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-21 14:03:29 -07:00
Use Series.OID (Tests still need to be updated)
CalendarModule working
This commit is contained in:
parent
f4170e90ad
commit
7d0d5ab943
24 changed files with 94 additions and 1035 deletions
|
@ -5,26 +5,35 @@ using System.Linq;
|
|||
using AutoMapper;
|
||||
using Nancy;
|
||||
using NzbDrone.Api.Extentions;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
namespace NzbDrone.Api.Calendar
|
||||
{
|
||||
public class CalendarModule : NzbDroneApiModule
|
||||
{
|
||||
private readonly UpcomingEpisodesProvider _upcomingEpisodesProvider;
|
||||
private readonly EpisodeService _episodeService;
|
||||
|
||||
public CalendarModule(UpcomingEpisodesProvider upcomingEpisodesProvider)
|
||||
: base("/Calendar")
|
||||
public CalendarModule(EpisodeService episodeService)
|
||||
: base("/calendar")
|
||||
{
|
||||
_upcomingEpisodesProvider = upcomingEpisodesProvider;
|
||||
_episodeService = episodeService;
|
||||
Get["/"] = x => Calendar();
|
||||
}
|
||||
|
||||
private Response Calendar()
|
||||
{
|
||||
var upcoming = _upcomingEpisodesProvider.UpcomingEpisodes();
|
||||
return Mapper.Map<List<Episode>, List<CalendarResource>>(upcoming).AsResponse();
|
||||
var year = DateTime.Now.Year;
|
||||
var month = DateTime.Now.Month;
|
||||
|
||||
var yearQuery = Request.Query.Year;
|
||||
var monthQuery = Request.Query.Month;
|
||||
|
||||
if (yearQuery.HasValue) year = Convert.ToInt32(yearQuery.Value);
|
||||
|
||||
if(monthQuery.HasValue) month = Convert.ToInt32(monthQuery.Value);
|
||||
|
||||
var episodes = _episodeService.GetEpisodesAiredInMonth(year, month);
|
||||
return Mapper.Map<List<Episode>, List<CalendarResource>>(episodes).AsResponse();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue