A simple yet robust RESTful API built with ASP.NET Core for managing a to-do list. This project demonstrates core backend development principles including CRUD operations, data persistence with Entity Framework Core, and automated unit testing.
- Full CRUD Functionality: Create, Read, Update, and Delete to-do items.
- Data Persistence: Data is saved to a persistent database using Entity Framework Core, ensuring that tasks are not lost when the application restarts.
- Unit Tested: The application's business logic is verified with a suite of unit tests using the xUnit framework to ensure reliability and correctness.
- Dependency Injection: Follows modern software design principles by using Dependency Injection to manage dependencies like the database context.
- Swagger Documentation: Includes an interactive Swagger UI for easy exploration and testing of the API endpoints.
- Backend: C#, ASP.NET Core 8
- Database: Entity Framework Core with SQLite (for local development)
- Testing: xUnit
- API Documentation: Swashbuckle (Swagger)
- .NET 8 SDK
- A code editor like Visual Studio or VS Code
-
Clone the repository:
git clone [Your GitHub Repository URL]
-
Navigate to the project directory:
cd TodoAPI -
Restore dependencies:
dotnet restore
-
Run the database migrations: The project is configured to use a simple SQLite database. The following command will create the
TodoApp.dbfile and set up the necessary tables.dotnet ef database update
-
Run the application:
dotnet run
The API will be available at
https://localhost:7212(or a similar port). You can access the interactive Swagger documentation by navigating tohttps://localhost:7212/swagger.
All endpoints are relative to the base URL (e.g., https://localhost:7212/api/todos).
-
GET /api/todos- Description: Retrieves a list of all to-do items.
- Response:
200 OKwith an array of to-do objects.
-
POST /api/todos- Description: Creates a new to-do item.
- Request Body:
{ "text": "Learn to deploy to Azure" } - Response:
201 Createdwith the newly created to-do object.
-
PUT /api/todos/{id}- Description: Updates an existing to-do item.
- Request Body:
{ "text": "Deploy the app to Azure", "done": true } - Response:
200 OKwith the updated to-do object.
-
DELETE /api/todos/{id}- Description: Deletes a specific to-do item.
- Response:
204 No Content.