diff --git a/API/Controllers/DTOs/MinimalManga.cs b/API/Controllers/DTOs/MinimalManga.cs index 4d75fc1..32e4ad8 100644 --- a/API/Controllers/DTOs/MinimalManga.cs +++ b/API/Controllers/DTOs/MinimalManga.cs @@ -1,5 +1,21 @@ +using System.ComponentModel.DataAnnotations; using API.Schema.MangaContext; +using Newtonsoft.Json; namespace API.Controllers.DTOs; -public sealed record MinimalManga(string Key, string Name, string Description, MangaReleaseStatus ReleaseStatus); \ No newline at end of file +public sealed record MinimalManga(string Key, string Name, string Description, MangaReleaseStatus ReleaseStatus, IEnumerable>? MangaConnectorIds = null) +{ + [Required] [StringLength(TokenGen.MaximumLength, MinimumLength = TokenGen.MinimumLength)] + public string Key { get; init; } = Key; + [Required] + [JsonRequired] + public string Name { get; init; } = Name; + [Required] + [JsonRequired] + public string Description { get; init; } = Description; + [Required] + [JsonRequired] + public MangaReleaseStatus ReleaseStatus { get; init; } = ReleaseStatus; + public IEnumerable>? MangaConnectorIds { get; init; } = MangaConnectorIds; +} \ No newline at end of file diff --git a/API/Controllers/MangaController.cs b/API/Controllers/MangaController.cs index 6381244..006ff2d 100644 --- a/API/Controllers/MangaController.cs +++ b/API/Controllers/MangaController.cs @@ -67,7 +67,7 @@ public class MangaController(MangaContext context) : Controller .ToArrayAsync(HttpContext.RequestAborted) is not { } result) return StatusCode(Status500InternalServerError); - return Ok(result.Select(m => new MinimalManga(m.Key, m.Name, m.Description, m.ReleaseStatus))); + return Ok(result.Select(m => new MinimalManga(m.Key, m.Name, m.Description, m.ReleaseStatus, m.MangaConnectorIds))); } /// diff --git a/API/Controllers/SearchController.cs b/API/Controllers/SearchController.cs index 7d38834..eb02f41 100644 --- a/API/Controllers/SearchController.cs +++ b/API/Controllers/SearchController.cs @@ -1,3 +1,4 @@ +using API.Controllers.DTOs; using API.MangaConnectors; using API.Schema.MangaContext; using Asp.Versioning; @@ -17,11 +18,11 @@ public class SearchController(MangaContext context) : Controller /// /// .Name /// searchTerm - /// + /// exert of . Use for more information /// with Name not found /// with Name is disabled [HttpGet("{MangaConnectorName}/{Query}")] - [ProducesResponseType(Status200OK, "application/json")] + [ProducesResponseType(Status200OK, "application/json")] [ProducesResponseType(Status404NotFound)] [ProducesResponseType(Status406NotAcceptable)] public IActionResult SearchManga (string MangaConnectorName, string Query) @@ -39,19 +40,19 @@ public class SearchController(MangaContext context) : Controller retMangas.Add(add); } - return Ok(retMangas.ToArray()); + return Ok(retMangas.Select(m => new MinimalManga(m.Key, m.Name, m.Description, m.ReleaseStatus, m.MangaConnectorIds))); } /// /// Returns from the associated with /// /// - /// + /// exert of . Use for more information /// Multiple found for URL /// not found /// Error during Database Operation [HttpPost("Url")] - [ProducesResponseType(Status200OK, "application/json")] + [ProducesResponseType(Status200OK, "application/json")] [ProducesResponseType(Status404NotFound)] [ProducesResponseType(Status500InternalServerError)] public IActionResult GetMangaFromUrl ([FromBody]string url) @@ -65,6 +66,6 @@ public class SearchController(MangaContext context) : Controller if(Tranga.AddMangaToContext(manga, context, out Manga? add, HttpContext.RequestAborted) == false) return StatusCode(Status500InternalServerError); - return Ok(add); + return Ok(new MinimalManga(add.Key, add.Name, add.Description, add.ReleaseStatus, add.MangaConnectorIds)); } } \ No newline at end of file