using API.Schema.MangaContext; using Asp.Versioning; using Microsoft.AspNetCore.Mvc; using static Microsoft.AspNetCore.Http.StatusCodes; // ReSharper disable InconsistentNaming namespace API.Controllers; [ApiVersion(2)] [ApiController] [Route("v{v:apiVersion}/[controller]")] public class QueryController(MangaContext context) : Controller { /// /// Returns the with /// /// .Key /// /// with not found [HttpGet("Author/{AuthorId}")] [ProducesResponseType(Status200OK, "application/json")] [ProducesResponseType(Status404NotFound)] public IActionResult GetAuthor(string AuthorId) { if (context.Authors.Find(AuthorId) is not { } author) return NotFound(); return Ok(author); } /// /// Returns with /// /// .Key /// /// with not found [HttpGet("Chapter/{ChapterId}")] [ProducesResponseType(Status200OK, "application/json")] [ProducesResponseType(Status404NotFound)] public IActionResult GetChapter(string ChapterId) { if (context.Chapters.Find(ChapterId) is not { } chapter) return NotFound(); return Ok(chapter); } /// /// Returns the with .Key /// /// Key of /// /// with not found [HttpGet("Manga/MangaConnectorId/{MangaConnectorIdId}")] [ProducesResponseType>(Status200OK, "application/json")] [ProducesResponseType(Status404NotFound)] public IActionResult GetMangaMangaConnectorId(string MangaConnectorIdId) { if(context.MangaConnectorToManga.Find(MangaConnectorIdId) is not { } mcIdManga) return NotFound(); return Ok(mcIdManga); } /// /// Returns the with .Key /// /// Key of /// /// with not found [HttpGet("chapter/MangaConnectorId/{MangaConnectorIdId}")] [ProducesResponseType>(Status200OK, "application/json")] [ProducesResponseType(Status404NotFound)] public IActionResult GetChapterMangaConnectorId(string MangaConnectorIdId) { if(context.MangaConnectorToChapter.Find(MangaConnectorIdId) is not { } mcIdChapter) return NotFound(); return Ok(mcIdChapter); } }