This is a simple .NET Web API project for managing books, created to explore .NET 8 with Entity Framework Core using an in-memory database. The project follows the repository pattern to handle book-related operations.
The project is a RESTful Web API that provides endpoints to perform CRUD operations on books. It utilizes Entity Framework Core with an in-memory database for data storage.
- Get All Books: Retrieve a list of all books.
- Add Book: Add a new book to the database.
- Delete Book: Delete a book by its ID.
- Update Book: Update an existing book.
- Get Book by ID: Retrieve a specific book by its ID.
Before you begin, ensure you have the following prerequisites:
- .NET 8 SDK installed. Download here
- An Integrated Development Environment (IDE) like Visual Studio or Visual Studio Code.
- Git installed. Download here
-
Clone the repository:
git clone https://github.com/RahulMule/DotNetWebAPI_InMemoryDatabase.git
-
Open the project in your preferred IDE.
-
Build the solution.
-
Run the application.
The API provides the following endpoints:
-
GET /api/books: Retrieve a list of all books.
-
POST /api/books: Add a new book to the database.
Example Request:
{ "title": "The Great Gatsby", "description": "A novel by F. Scott Fitzgerald", "author": "F. Scott Fitzgerald", "price": 10.99 }
Example Response:
{ "status": "OK" }
-
GET /api/books/{id}: Retrieve a specific book by its ID.
Example Response:
{ "id": 1, "title": "The Great Gatsby", "description": "A novel by F. Scott Fitzgerald", "author": "F. Scott Fitzgerald", "price": 10.99 }
-
DELETE /api/books/{id}: Delete a book by its ID.
-
PUT /api/books: Update an existing book.
Example Request:
{ "id": 1, "title": "New Title", "description": "Updated description", "author": "Updated Author", "price": 19.99 }
Example Response:
{ "status": "OK" }
Feel free to explore and customize the code to suit your needs.
Contributions are welcome! Fork the repository, make your changes, and submit a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.