Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/marchena96/Paradigma-lab1/llms.txt

Use this file to discover all available pages before exploring further.

Permanently removes a Library record from the database. The controller first checks whether the library exists; if it does not, it returns 404 immediately. When the library is found it is passed to LibrariesService.Delete, which calls EF Core’s Remove and flushes the change with SaveChangesAsync.
Cascade delete is in effect. The Book entity has a foreign key LibraryId pointing to Library. When a library is deleted, the database ON DELETE CASCADE constraint automatically removes all books belonging to that library from the Books table. This action is irreversible.

Endpoint

DELETE /api/libraries/{libraryId}

Authentication

No authentication is required. The Delete action does not carry an [Authorize] attribute.

Path Parameters

libraryId
integer
required
The unique integer ID of the library to delete. The controller performs an existence check against this value before proceeding with the deletion.

Response

204 No Content

Returned when the library (and its cascaded books) has been successfully deleted. The response body is empty.

404 Not Found

Returned when no library with the given libraryId exists. No deletion is performed. The response body is empty.

Status Codes

StatusMeaning
204No Content — the library was deleted successfully.
404Not Found — no library with the given libraryId was found.

Controller Source

[HttpDelete("{libraryId}")]
public async Task<IActionResult> Delete(int libraryId)
{
    var library = (await _librariesService.Get(new[] { libraryId })).FirstOrDefault();
    if (library == null)
        return NotFound();

    await _librariesService.Delete(library);
    return NoContent();
}

Example Request

curl -X DELETE https://localhost:7098/api/libraries/5

Example Response

A 204 No Content response has no body. A successful deletion looks like this at the HTTP level:
HTTP/1.1 204 No Content

Build docs developers (and LLMs) love