This commit is contained in:
RodoIsAlnum
2025-10-28 20:59:38 -06:00
parent fef5ca6aa6
commit 10c131cd47
329 changed files with 3454 additions and 303 deletions

View File

@@ -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();
}
}
}
}