mirror of
https://github.com/C9Glax/tranga.git
synced 2025-05-22 06:03:01 +02:00
MangaController.cs use Manga.Chapters for Navigation instead of new context-Request
This commit is contained in:
parent
6cfa29e3dd
commit
0903ec606b
@ -153,12 +153,11 @@ public class MangaController(PgsqlContext context, ILog Log) : Controller
|
|||||||
[ProducesResponseType(Status404NotFound)]
|
[ProducesResponseType(Status404NotFound)]
|
||||||
public IActionResult GetChapters(string MangaId)
|
public IActionResult GetChapters(string MangaId)
|
||||||
{
|
{
|
||||||
Manga? m = context.Mangas.Find(MangaId);
|
if(context.Mangas.Find(MangaId) is not { } m)
|
||||||
if (m is null)
|
|
||||||
return NotFound();
|
return NotFound();
|
||||||
|
|
||||||
Chapter[] ret = context.Chapters.Where(c => c.ParentMangaId == m.MangaId).ToArray();
|
Chapter[] chapters = m.Chapters.ToArray();
|
||||||
return Ok(ret);
|
return Ok(chapters);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -174,11 +173,10 @@ public class MangaController(PgsqlContext context, ILog Log) : Controller
|
|||||||
[ProducesResponseType(Status404NotFound)]
|
[ProducesResponseType(Status404NotFound)]
|
||||||
public IActionResult GetChaptersDownloaded(string MangaId)
|
public IActionResult GetChaptersDownloaded(string MangaId)
|
||||||
{
|
{
|
||||||
Manga? m = context.Mangas.Find(MangaId);
|
if(context.Mangas.Find(MangaId) is not { } m)
|
||||||
if (m is null)
|
|
||||||
return NotFound();
|
return NotFound();
|
||||||
|
|
||||||
List<Chapter> chapters = context.Chapters.Where(c => c.ParentMangaId == m.MangaId && c.Downloaded == true).ToList();
|
List<Chapter> chapters = m.Chapters.ToList();
|
||||||
if (chapters.Count == 0)
|
if (chapters.Count == 0)
|
||||||
return NoContent();
|
return NoContent();
|
||||||
|
|
||||||
@ -198,11 +196,10 @@ public class MangaController(PgsqlContext context, ILog Log) : Controller
|
|||||||
[ProducesResponseType(Status404NotFound)]
|
[ProducesResponseType(Status404NotFound)]
|
||||||
public IActionResult GetChaptersNotDownloaded(string MangaId)
|
public IActionResult GetChaptersNotDownloaded(string MangaId)
|
||||||
{
|
{
|
||||||
Manga? m = context.Mangas.Find(MangaId);
|
if(context.Mangas.Find(MangaId) is not { } m)
|
||||||
if (m is null)
|
|
||||||
return NotFound();
|
return NotFound();
|
||||||
|
|
||||||
List<Chapter> chapters = context.Chapters.Where(c => c.ParentMangaId == m.MangaId && c.Downloaded == false).ToList();
|
List<Chapter> chapters = m.Chapters.ToList();
|
||||||
if (chapters.Count == 0)
|
if (chapters.Count == 0)
|
||||||
return NoContent();
|
return NoContent();
|
||||||
|
|
||||||
@ -226,11 +223,10 @@ public class MangaController(PgsqlContext context, ILog Log) : Controller
|
|||||||
[ProducesResponseType<int>(Status503ServiceUnavailable, "text/plain")]
|
[ProducesResponseType<int>(Status503ServiceUnavailable, "text/plain")]
|
||||||
public IActionResult GetLatestChapter(string MangaId)
|
public IActionResult GetLatestChapter(string MangaId)
|
||||||
{
|
{
|
||||||
Manga? m = context.Mangas.Find(MangaId);
|
if(context.Mangas.Find(MangaId) is not { } m)
|
||||||
if (m is null)
|
|
||||||
return NotFound();
|
return NotFound();
|
||||||
|
|
||||||
List<Chapter> chapters = context.Chapters.Where(c => c.ParentMangaId == m.MangaId).ToList();
|
List<Chapter> chapters = m.Chapters.ToList();
|
||||||
if (chapters.Count == 0)
|
if (chapters.Count == 0)
|
||||||
{
|
{
|
||||||
List<Job> retrieveChapterJobs = context.Jobs.Where(j => j.JobType == JobType.RetrieveChaptersJob).ToList();
|
List<Job> retrieveChapterJobs = context.Jobs.Where(j => j.JobType == JobType.RetrieveChaptersJob).ToList();
|
||||||
@ -266,12 +262,10 @@ public class MangaController(PgsqlContext context, ILog Log) : Controller
|
|||||||
[ProducesResponseType<int>(Status503ServiceUnavailable, "text/plain")]
|
[ProducesResponseType<int>(Status503ServiceUnavailable, "text/plain")]
|
||||||
public IActionResult GetLatestChapterDownloaded(string MangaId)
|
public IActionResult GetLatestChapterDownloaded(string MangaId)
|
||||||
{
|
{
|
||||||
Manga? m = context.Mangas.Find(MangaId);
|
if(context.Mangas.Find(MangaId) is not { } m)
|
||||||
if (m is null)
|
|
||||||
return NotFound();
|
return NotFound();
|
||||||
|
|
||||||
|
List<Chapter> chapters = m.Chapters.ToList();
|
||||||
List<Chapter> chapters = context.Chapters.Where(c => c.ParentMangaId == m.MangaId && c.Downloaded == true).ToList();
|
|
||||||
if (chapters.Count == 0)
|
if (chapters.Count == 0)
|
||||||
{
|
{
|
||||||
List<Job> retrieveChapterJobs = context.Jobs.Where(j => j.JobType == JobType.RetrieveChaptersJob).ToList();
|
List<Job> retrieveChapterJobs = context.Jobs.Where(j => j.JobType == JobType.RetrieveChaptersJob).ToList();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user