Final
This commit is contained in:
@@ -35,13 +35,13 @@ namespace BibliotecaAPI.Controllers
|
||||
{
|
||||
_context.Libros.Add(libro);
|
||||
await _context.SaveChangesAsync();
|
||||
return CreatedAtAction(nameof(GetLibro), new { id = libro.IdLibro }, libro);
|
||||
return CreatedAtAction(nameof(GetLibro), new { id = libro.Id_Libro }, libro);
|
||||
}
|
||||
|
||||
[HttpPut("{id}")]
|
||||
public async Task<IActionResult> PutLibro(int id, Libro libro)
|
||||
{
|
||||
if (id != libro.IdLibro) return BadRequest();
|
||||
if (id != libro.Id_Libro) return BadRequest();
|
||||
_context.Entry(libro).State = EntityState.Modified;
|
||||
await _context.SaveChangesAsync();
|
||||
return NoContent();
|
||||
@@ -50,11 +50,11 @@ namespace BibliotecaAPI.Controllers
|
||||
[HttpDelete("{id}")]
|
||||
public async Task<IActionResult> DeleteLibro(int id)
|
||||
{
|
||||
var libro = await _context.Libros.FindAsync(IdLibro);
|
||||
var libro = await _context.Libros.FindAsync(id);
|
||||
if (libro == null) return NotFound();
|
||||
_context.Libros.Remove(libro);
|
||||
await _context.SaveChangesAsync();
|
||||
return NoContent();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user