From 3ba1261f31ace008dc15c7e8c1e0924afd6b7458 Mon Sep 17 00:00:00 2001 From: Glax Date: Thu, 13 Mar 2025 17:23:52 +0100 Subject: [PATCH] Add Endpoints to retrieve all (not-)Downloaded Chapters --- API/Controllers/MangaController.cs | 48 ++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/API/Controllers/MangaController.cs b/API/Controllers/MangaController.cs index 69bd6ba..e88b0a5 100644 --- a/API/Controllers/MangaController.cs +++ b/API/Controllers/MangaController.cs @@ -146,6 +146,54 @@ public class MangaController(PgsqlContext context) : Controller return Ok(ret); } + /// + /// Returns all downloaded Chapters for Manga with ID + /// + /// Manga-ID + /// + /// No available chapters + /// Manga with ID not found. + [HttpGet("{MangaId}/Chapters/Downloaded")] + [ProducesResponseType(Status200OK, "application/json")] + [ProducesResponseType(Status204NoContent)] + [ProducesResponseType(Status404NotFound)] + public IActionResult GetChaptersDownloaded(string MangaId) + { + Manga? m = context.Manga.Find(MangaId); + if (m is null) + return NotFound(); + + List chapters = context.Chapters.Where(c => c.ParentMangaId == m.MangaId && c.Downloaded == true).ToList(); + if (chapters.Count == 0) + return NoContent(); + + return Ok(chapters); + } + + /// + /// Returns all Chapters not downloaded for Manga with ID + /// + /// Manga-ID + /// + /// No available chapters + /// Manga with ID not found. + [HttpGet("{MangaId}/Chapters/NotDownloaded")] + [ProducesResponseType(Status200OK, "application/json")] + [ProducesResponseType(Status204NoContent)] + [ProducesResponseType(Status404NotFound)] + public IActionResult GetChaptersNotDownloaded(string MangaId) + { + Manga? m = context.Manga.Find(MangaId); + if (m is null) + return NotFound(); + + List chapters = context.Chapters.Where(c => c.ParentMangaId == m.MangaId && c.Downloaded == false).ToList(); + if (chapters.Count == 0) + return NoContent(); + + return Ok(chapters); + } + /// /// Returns the latest Chapter of requested Manga available on Website ///