Sonarr/NzbDrone.Services.Api/DailySeries/DailySeriesModule.cs

37 lines
999 B
C#
Raw Normal View History

2013-01-29 01:07:18 +00:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Nancy;
using NzbDrone.Services.Api.Extensions;
2013-01-29 01:07:18 +00:00
namespace NzbDrone.Services.Api.DailySeries
{
public class DailySeriesModule : NancyModule
{
2013-02-01 04:18:11 +00:00
private readonly DailySeriesRepository _dailySeriesRepository;
2013-01-29 01:07:18 +00:00
2013-02-01 04:18:11 +00:00
public DailySeriesModule(DailySeriesRepository dailySeriesRepository)
2013-01-29 01:07:18 +00:00
: base("/dailyseries")
{
2013-02-01 04:18:11 +00:00
_dailySeriesRepository = dailySeriesRepository;
2013-01-29 01:07:18 +00:00
Get["/"] = x => OnGet();
Get["/all"] = x => OnGet();
Get["/{Id}"] = x => OnGet((int)x.Id);
Get["/isdaily/{Id}"] = x => OnGet((int)x.Id);
}
private Response OnGet()
{
2013-02-01 04:18:11 +00:00
return _dailySeriesRepository.Public().AsResponse();
2013-01-29 01:07:18 +00:00
}
private Response OnGet(int seriesId)
{
2013-02-01 04:18:11 +00:00
var result = _dailySeriesRepository.Find(seriesId) != null;
return result.AsResponse();
2013-01-29 01:07:18 +00:00
}
}
}