From 7a451e5924a9db501bcbe76c3e93e3c286cb6d38 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sat, 18 Apr 2020 11:48:38 +0200 Subject: [PATCH] Can delete a movie --- src/controllers/MoviesController.ts | 13 +++++++++++++ src/controllers/Routes.ts | 2 ++ 2 files changed, 15 insertions(+) diff --git a/src/controllers/MoviesController.ts b/src/controllers/MoviesController.ts index 2c8a76d..bc4aa96 100644 --- a/src/controllers/MoviesController.ts +++ b/src/controllers/MoviesController.ts @@ -21,6 +21,19 @@ export class MoviesController { h.send(list.map((m) => this.MovieToAPI(m))); } + /** + * Delete a movie + * + * @param h Request handler + */ + public static async Delete(h: RequestHandler) { + const movieID = await h.postMovieID("movieID"); + + await MoviesHelper.Delete(await MoviesHelper.GetInfo(movieID)); + + h.success(); + } + /** * Turn a movie into an API entry * diff --git a/src/controllers/Routes.ts b/src/controllers/Routes.ts index f33b8ae..4a8b371 100644 --- a/src/controllers/Routes.ts +++ b/src/controllers/Routes.ts @@ -293,6 +293,8 @@ export const Routes : Route[] = [ // Movies controller {path: "/movies/get_list", cb: (h) => MoviesController.GetList(h)}, + {path: "/movies/delete", cb: (h) => MoviesController.Delete(h)}, + // Virtual directory controller