A RESTful Web API built with C# and ASP.NET Core for managing a library of books.
This project was developed to practice ASP.NET Core Web API, layered architecture, dependency injection, DTOs, business rules, validation, exception handling, and RESTful API development.
- C#
- .NET
- ASP.NET Core Web API
- Swagger / OpenAPI
- Visual Studio
- List all books
- Get a book by ID
- Create a book
- Update a book
- Delete a book
- Input validation
- Business rule validation
- Genre validation and conversion
- Duplicate book validation
CreatedAtandUpdatedAttimestamps- HTTP status code handling
- Book title and author combination cannot be duplicated.
- Price cannot be negative.
- Stock cannot be negative.
- Genre must be valid.
CreatedAtis set when a book is created.UpdatedAtis updated when a book is modified.
Responsible for handling HTTP requests and responses, route parameters, and HTTP status codes.
Responsible for business rules such as price, stock, genre, and duplicate book validation.
Used to separate API request/response models from the internal Book model.
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/books |
Get all books |
| GET | /api/books/{id} |
Get a book by ID |
| POST | /api/books |
Create a book |
| PUT | /api/books/{id} |
Update a book |
| DELETE | /api/books/{id} |
Delete a book |
Through this project, I practiced:
- ASP.NET Core Web API fundamentals
- RESTful API design
- HTTP methods and status codes
- Dependency Injection
- Layered Organization (Folders)
- DTOs
- Business rule implementation
- Input validation
- Exception handling
- LINQ
- Debugging with Visual Studio
Make sure you have installed:
- .NET SDK
- Visual Studio 2022 or another C#/.NET IDE
git clone https://github.com/AnaLinsDev/library-api.gitcd LibraryAPIdotnet restoredotnet builddotnet runThe terminal will display the URL where the API is running.
Open the Swagger URL displayed by the application in your browser.
Swagger can be used to test the available API endpoints without requiring Postman or another API client.