Add endpoint that fetches all Metadataentries for Manga

This commit is contained in:
2025-10-14 10:42:30 +02:00
parent 4281c93f9a
commit b6aab4eb8d
2 changed files with 56 additions and 1 deletions

View File

@@ -36,12 +36,28 @@ public class MetadataFetcherController(MangaContext context) : Controller
[ProducesResponseType(Status500InternalServerError)]
public async Task<Results<Ok<List<MetadataEntry>>, InternalServerError>> GetLinkedEntries ()
{
if (await context.MetadataEntries.ToListAsync() is not { } result)
if (await context.MetadataEntries.ToListAsync(HttpContext.RequestAborted) is not { } result)
return TypedResults.InternalServerError();
return TypedResults.Ok(result);
}
/// <summary>
/// Returns all <see cref="MetadataEntry"/> for <see cref="Manga"/> with <paramref name="MangaId"/>
/// </summary>
/// <response code="200"></response>
/// <response code="404"><see cref="Manga"/> with <paramref name="MangaId"/> not found</response>
[HttpGet("Links/{MangaId}")]
[ProducesResponseType<List<MetadataEntry>>(Status200OK, "application/json")]
[ProducesResponseType(Status500InternalServerError)]
public async Task<Results<Ok<List<MetadataEntry>>, NotFound<string>>> GetLinkedEntries(string MangaId)
{
if (await context.MetadataEntries.Where(me => me.MangaId == MangaId).ToListAsync(HttpContext.RequestAborted) is not { } result)
return TypedResults.NotFound(nameof(MangaId));
return TypedResults.Ok(result);
}
/// <summary>
/// Searches <see cref="MetadataFetcher"/> (Metadata-Sites) for Manga-Metadata
/// </summary>