From 8fc93c76283b8a8cc1a5b18e7c294ba3b302ba33 Mon Sep 17 00:00:00 2001 From: kayone Date: Sun, 1 Dec 2013 16:30:30 -0800 Subject: [PATCH] Added missing GetResourceById to CalendarModule needed by signalr --- src/NzbDrone.Api/Calendar/CalendarModule.cs | 6 ++++++ src/NzbDrone.Api/REST/RestModule.cs | 22 +++++++++++---------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/NzbDrone.Api/Calendar/CalendarModule.cs b/src/NzbDrone.Api/Calendar/CalendarModule.cs index 22f01c6cc..8a7df0dab 100644 --- a/src/NzbDrone.Api/Calendar/CalendarModule.cs +++ b/src/NzbDrone.Api/Calendar/CalendarModule.cs @@ -29,6 +29,12 @@ namespace NzbDrone.Api.Calendar _seriesRepository = seriesRepository; GetResourceAll = GetCalendar; + GetResourceById = GetEpisode; + } + + private EpisodeResource GetEpisode(int id) + { + return _episodeService.GetEpisode(id).InjectTo(); } private List GetCalendar() diff --git a/src/NzbDrone.Api/REST/RestModule.cs b/src/NzbDrone.Api/REST/RestModule.cs index 9a576d360..1efcf0b3a 100644 --- a/src/NzbDrone.Api/REST/RestModule.cs +++ b/src/NzbDrone.Api/REST/RestModule.cs @@ -37,12 +37,24 @@ namespace NzbDrone.Api.REST protected RestModule(string modulePath) : base(modulePath) { + ValidateModule(); PostValidator = new ResourceValidator(); PutValidator = new ResourceValidator(); SharedValidator = new ResourceValidator(); } + + private void ValidateModule() + { + if (GetResourceById != null) return; + + if (CreateResource != null || UpdateResource != null) + { + throw new InvalidOperationException("GetResourceById route must be defined before defining Create/Update routes."); + } + } + protected Action DeleteResource { private get { return _deleteResource; } @@ -137,7 +149,6 @@ namespace NzbDrone.Api.REST private get { return _createResource; } set { - EnsureGetByIdRoute(); _createResource = value; Post[ROOT_ROUTE] = options => { @@ -148,15 +159,6 @@ namespace NzbDrone.Api.REST } } - private void EnsureGetByIdRoute() - { - if (GetResourceById == null) - { - throw new InvalidOperationException( - "GetResourceById route must be defined before defining Create/Update routes."); - } - } - protected Action UpdateResource { private get { return _updateResource; }