added support for getting series by slug

This commit is contained in:
Keivan Beigi 2013-05-03 19:30:44 -07:00
commit 8373e1ce10
3 changed files with 30 additions and 0 deletions

View file

@ -2,9 +2,11 @@
using System.Collections.Generic;
using System.Linq;
using FluentValidation;
using Nancy;
using NzbDrone.Core.SeriesStats;
using NzbDrone.Core.Tv;
using NzbDrone.Api.Validation;
using NzbDrone.Api.Extensions;
namespace NzbDrone.Api.Series
{
@ -25,15 +27,30 @@ namespace NzbDrone.Api.Series
UpdateResource = UpdateSeries;
DeleteResource = DeleteSeries;
Get["/{slug}"] = o => GetSeries((string)o.slug.ToString());
SharedValidator.RuleFor(s => s.RootFolderId).ValidId();
SharedValidator.RuleFor(s => s.QualityProfileId).ValidId();
PostValidator.RuleFor(s => s.Title).NotEmpty();
}
private Response GetSeries(string slug)
{
var series = _seriesService.FindBySlug(slug);
if (series == null)
{
return new NotFoundResponse();
}
return series.AsResponse();
}
private List<SeriesResource> AllSeries()
{
var seriesStats = _seriesStatisticsService.SeriesStatistics();