diff --git a/RMuseum/Controllers/PDFLibraryController.cs b/RMuseum/Controllers/PDFLibraryController.cs index 284ec1af..9666413b 100644 --- a/RMuseum/Controllers/PDFLibraryController.cs +++ b/RMuseum/Controllers/PDFLibraryController.cs @@ -510,6 +510,32 @@ namespace RMuseum.Controllers return Ok(authorsRes.Result.Authors); } + /// + /// get author by id + /// + /// + /// + [HttpGet("author/{id}")] + [AllowAnonymous] + [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(Author))] + [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] + + public async Task GetAuthorByIdAsync(int id) + { + var authorsRes = await _pdfService.GetAuthorByIdAsync(id); + if (!string.IsNullOrEmpty(authorsRes.ExceptionString)) + { + return BadRequest(authorsRes.ExceptionString); + } + + if(authorsRes.Result == null) + { + return NotFound(); + } + + return Ok(authorsRes.Result); + } + /// /// add a new author /// diff --git a/RMuseum/RMuseum.xml b/RMuseum/RMuseum.xml index 113905d2..1e997e22 100644 --- a/RMuseum/RMuseum.xml +++ b/RMuseum/RMuseum.xml @@ -2454,6 +2454,13 @@ + + + get author by id + + + + add a new author