From 683bda49d84cd4f935abd0b1ed10e11f3b212c83 Mon Sep 17 00:00:00 2001 From: Leonardo Galli Date: Tue, 10 Jan 2017 16:51:56 +0100 Subject: [PATCH] Movie Editor works now. Fixes #99. --- src/NzbDrone.Api/Movies/MovieEditorModule.cs | 31 ++++++++++++++++++++ src/NzbDrone.Api/NzbDrone.Api.csproj | 1 + 2 files changed, 32 insertions(+) create mode 100644 src/NzbDrone.Api/Movies/MovieEditorModule.cs diff --git a/src/NzbDrone.Api/Movies/MovieEditorModule.cs b/src/NzbDrone.Api/Movies/MovieEditorModule.cs new file mode 100644 index 000000000..ca744a099 --- /dev/null +++ b/src/NzbDrone.Api/Movies/MovieEditorModule.cs @@ -0,0 +1,31 @@ +using System.Collections.Generic; +using System.Linq; +using Nancy; +using NzbDrone.Api.Extensions; +using NzbDrone.Core.Tv; + +namespace NzbDrone.Api.Movie +{ + public class MovieEditorModule : NzbDroneApiModule + { + private readonly IMovieService _movieService; + + public MovieEditorModule(IMovieService movieService) + : base("/movie/editor") + { + _movieService = movieService; + Put["/"] = Movie => SaveAll(); + } + + private Response SaveAll() + { + var resources = Request.Body.FromJson>(); + + var Movie = resources.Select(MovieResource => MovieResource.ToModel(_movieService.GetMovie(MovieResource.Id))).ToList(); + + return _movieService.UpdateMovie(Movie) + .ToResource() + .AsResponse(HttpStatusCode.Accepted); + } + } +} diff --git a/src/NzbDrone.Api/NzbDrone.Api.csproj b/src/NzbDrone.Api/NzbDrone.Api.csproj index 2a3dcba5a..5486fe715 100644 --- a/src/NzbDrone.Api/NzbDrone.Api.csproj +++ b/src/NzbDrone.Api/NzbDrone.Api.csproj @@ -119,6 +119,7 @@ +