From 31c039d71e7e00bc5aee75a1a6211ddaed8c588f Mon Sep 17 00:00:00 2001 From: Glax Date: Mon, 17 Mar 2025 20:16:39 +0100 Subject: [PATCH] Change Endpoint to move Manga --- API/Controllers/MangaController.cs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/API/Controllers/MangaController.cs b/API/Controllers/MangaController.cs index b3ac3c9..bb0c311 100644 --- a/API/Controllers/MangaController.cs +++ b/API/Controllers/MangaController.cs @@ -292,24 +292,30 @@ public class MangaController(PgsqlContext context) : Controller return StatusCode(500, e.Message); } } - + /// - /// Move the Directory the .cbz-files are located in + /// Move Manga to different Library /// /// Manga-ID - /// New Directory-Path + /// Library-Id /// Folder is going to be moved + /// MangaId or LibraryId not found /// Error during Database Operation - [HttpPost("{MangaId}/MoveFolder")] + [HttpPost("{MangaId}/ChangeLibrary/{LibraryId}")] [ProducesResponseType(Status202Accepted)] + [ProducesResponseType(Status404NotFound)] [ProducesResponseType(Status500InternalServerError, "text/plain")] - public IActionResult MoveFolder(string MangaId, [FromBody]string folder) + public IActionResult MoveFolder(string MangaId, string LibraryId) { Manga? manga = context.Mangas.Find(MangaId); if (manga is null) return NotFound(); - MoveFileOrFolderJob dep = manga.UpdateFolderName(TrangaSettings.downloadLocation, folder); - UpdateFilesDownloadedJob up = new UpdateFilesDownloadedJob(0, manga.MangaId, null, [dep.JobId]); + LocalLibrary? library = context.LocalLibraries.Find(LibraryId); + if (library is null) + return NotFound(); + + MoveMangaLibraryJob dep = new (MangaId, LibraryId); + UpdateFilesDownloadedJob up = new (0, manga.MangaId, null, [dep.JobId]); try {