diff options
author | HombreLaser <sebastian-440@live.com> | 2022-09-20 20:21:39 -0500 |
---|---|---|
committer | HombreLaser <sebastian-440@live.com> | 2022-09-20 20:21:39 -0500 |
commit | 766d9635dc09886707213cdbafa8a783a143ce84 (patch) | |
tree | 97e8d52a6b42e88fa802eb522b792ea213330992 /Controllers/AuthorsController.cs | |
parent | 07d82966b9d2d4adddcb6e80367f60726801fc20 (diff) |
Añadidas más rutas
Diffstat (limited to 'Controllers/AuthorsController.cs')
-rw-r--r-- | Controllers/AuthorsController.cs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/Controllers/AuthorsController.cs b/Controllers/AuthorsController.cs index 845708b..647a7e5 100644 --- a/Controllers/AuthorsController.cs +++ b/Controllers/AuthorsController.cs @@ -13,7 +13,7 @@ namespace LibraryAPI.Controllers { } [HttpGet] - public async Task<ActionResult<IEnumerable<Author>>> getAuthors() { + public async Task<ActionResult<IEnumerable<Author>>> GetAuthors() { if(_context.Authors == null) { return NotFound(); } @@ -34,6 +34,18 @@ namespace LibraryAPI.Controllers { return author; } + // Obtener los libros de un autor. + [HttpGet("{id}/books")] + public async Task<ActionResult<IEnumerable<Book>>> GetAuthorBooks(long id) { + return await _context.Books.Where(x => x.AuthorId == id).ToListAsync(); + } + + // Obtener primer objeto de la tabla. + [HttpGet("first")] + public async Task<ActionResult<Author>> GetFirst() { + return await _context.Authors.FirstOrDefaultAsync(); + } + [HttpPut("{id}")] public async Task<ActionResult> PutAuthor(long id, Author author) { if(id != author.Id) |