From 766d9635dc09886707213cdbafa8a783a143ce84 Mon Sep 17 00:00:00 2001 From: HombreLaser Date: Tue, 20 Sep 2022 20:21:39 -0500 Subject: Añadidas más rutas MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Controllers/AuthorsController.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'Controllers/AuthorsController.cs') 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>> getAuthors() { + public async Task>> 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>> GetAuthorBooks(long id) { + return await _context.Books.Where(x => x.AuthorId == id).ToListAsync(); + } + + // Obtener primer objeto de la tabla. + [HttpGet("first")] + public async Task> GetFirst() { + return await _context.Authors.FirstOrDefaultAsync(); + } + [HttpPut("{id}")] public async Task PutAuthor(long id, Author author) { if(id != author.Id) -- cgit v1.2.3