diff --git a/src/NzbDrone.Api/Calendar/CalendarModule.cs b/src/NzbDrone.Api/Calendar/CalendarModule.cs index 22f01c6cce..8a7df0daba 100644 --- a/src/NzbDrone.Api/Calendar/CalendarModule.cs +++ b/src/NzbDrone.Api/Calendar/CalendarModule.cs @@ -29,6 +29,12 @@ public CalendarModule(ICommandExecutor commandExecutor, _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 9a576d360d..1efcf0b3a3 100644 --- a/src/NzbDrone.Api/REST/RestModule.cs +++ b/src/NzbDrone.Api/REST/RestModule.cs @@ -37,12 +37,24 @@ protected void ValidateId(int id) 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 @@ protected Func CreateResource private get { return _createResource; } set { - EnsureGetByIdRoute(); _createResource = value; Post[ROOT_ROUTE] = options => { @@ -148,15 +159,6 @@ protected Func CreateResource } } - 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; }