From 8408407a8e18222b5c21ee20aaab0e3e4ad370a7 Mon Sep 17 00:00:00 2001 From: glax Date: Mon, 21 Jul 2025 12:32:20 +0200 Subject: [PATCH] Search for Manga on different MangaConnector --- API/Controllers/MangaController.cs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/API/Controllers/MangaController.cs b/API/Controllers/MangaController.cs index 3150039..55b2278 100644 --- a/API/Controllers/MangaController.cs +++ b/API/Controllers/MangaController.cs @@ -412,7 +412,7 @@ public class MangaController(MangaContext context) : Controller { if (context.Mangas.Find(MangaId) is null) return NotFound(nameof(MangaId)); - if(Tranga.MangaConnectors.FirstOrDefault(c => c.Name.Equals(MangaConnectorName, StringComparison.InvariantCultureIgnoreCase)) is not { } connector) + if(!Tranga.TryGetMangaConnector(MangaConnectorName, out MangaConnector? mangaConnector)) return NotFound(nameof(MangaConnectorName)); if (context.MangaConnectorToManga @@ -436,4 +436,24 @@ public class MangaController(MangaContext context) : Controller return Ok(); } + + /// + /// Initiate a search for on a different + /// + /// with + /// .Name + /// + /// with Name not found + /// with Name is disabled + [HttpPost("{MangaId}/SearchOn/{MangaConnectorName}")] + [ProducesResponseType(Status200OK, "application/json")] + [ProducesResponseType(Status404NotFound)] + [ProducesResponseType(Status406NotAcceptable)] + public IActionResult SearchOnDifferentConnector(string MangaId, string MangaConnectorName) + { + if (context.Mangas.Find(MangaId) is not { } manga) + return NotFound(nameof(MangaId)); + + return new SearchController(context).SearchManga(MangaConnectorName, manga.Name); + } } \ No newline at end of file