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 ///