summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHombreLaser <sebastian-440@live.com>2022-09-15 18:41:11 -0500
committerHombreLaser <sebastian-440@live.com>2022-09-15 18:41:11 -0500
commit8901a18b0e26cf9ad0aa929e2f656a80cd2f4b09 (patch)
tree2455ac759f1eb0953854d177005086b5d995a9ec
parent68b94929d44e1f4ffbee4cadc4c54cc438f6634c (diff)
Cambiar URL del controlador
-rw-r--r--Controllers/BooksController.cs12
-rw-r--r--Models/Book.cs5
2 files changed, 11 insertions, 6 deletions
diff --git a/Controllers/BooksController.cs b/Controllers/BooksController.cs
index 5eeaa07..06e7055 100644
--- a/Controllers/BooksController.cs
+++ b/Controllers/BooksController.cs
@@ -9,7 +9,7 @@ using LibraryAPI.Models;
namespace LibraryAPI.Controllers
{
- [Route("api/[controller]")]
+ [Route("api/books")]
[ApiController]
public class BooksController : ControllerBase
{
@@ -20,7 +20,7 @@ namespace LibraryAPI.Controllers
_context = context;
}
- // GET: api/Books
+ // GET: api/books
[HttpGet]
public async Task<ActionResult<IEnumerable<Book>>> GetBooks()
{
@@ -31,7 +31,7 @@ namespace LibraryAPI.Controllers
return await _context.Books.ToListAsync();
}
- // GET: api/Books/5
+ // GET: api/books/5
[HttpGet("{id}")]
public async Task<ActionResult<Book>> GetBook(long id)
{
@@ -49,7 +49,7 @@ namespace LibraryAPI.Controllers
return book;
}
- // PUT: api/Books/5
+ // PUT: api/books/5
// To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754
[HttpPut("{id}")]
public async Task<IActionResult> PutBook(long id, Book book)
@@ -80,7 +80,7 @@ namespace LibraryAPI.Controllers
return NoContent();
}
- // POST: api/Books
+ // POST: api/books
// To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754
[HttpPost]
public async Task<ActionResult<Book>> PostBook(Book book)
@@ -95,7 +95,7 @@ namespace LibraryAPI.Controllers
return CreatedAtAction("GetBook", new { id = book.Id }, book);
}
- // DELETE: api/Books/5
+ // DELETE: api/books/5
[HttpDelete("{id}")]
public async Task<IActionResult> DeleteBook(long id)
{
diff --git a/Models/Book.cs b/Models/Book.cs
index 998a3ee..d648c12 100644
--- a/Models/Book.cs
+++ b/Models/Book.cs
@@ -1,5 +1,10 @@
+using System.ComponentModel.DataAnnotations.Schema;
+using System.ComponentModel.DataAnnotations;
+
namespace LibraryAPI.Models {
public class Book {
+ [Key]
+ [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long Id { get; set; }
public DateTime PublicationDate { get; set; }