This is a simple NetCore Web API that allows to register tasks.
Motivation: I made this project for learning purpose.
- Database connection with PostgresQL
- Code-First with Entity-Framework
- Dependency Injection pattern
- Swagger docs
-
Make sure you have installed the DotNet SDK (>= net8.0)
-
Clone this repository
-
Run the local database using Docker (If you already have a database just update the connection string in the
appsettings.json
file and skip this step)docker compose up
-
Open a terminal in the project directory and install the dependencies.
dotnet restore
-
Run the migrations.
dotnet ef database update
-
Run the server (development mode).
dotnet run
Documentation can also be found on http://localhost:5272/swagger/index.html.
Returns the list of categories.
curl -X GET http://localhost:5272/api/categories
[
{
"id": "string",
"createdAt": "string",
"updatedAt": "string",
"name": "string",
"description": "string",
"weight": 0
}
]
Returns the information of a single category by its ID.
curl -X GET http://localhost:5272/api/categories/{id}
{
"id": "string",
"createdAt": "string",
"updatedAt": "string",
"name": "string",
"description": "string",
"weight": 0
}
Creates a new category.
curl -X POST -H 'Content-Type:application/json' http://localhost:5272/api/categories -d '{"name":"string","description":"string","weight":0}'
{
"id": "string",
"createdAt": "string",
"updatedAt": "string",
"name": "string",
"description": "string",
"weight": 0
}
Updates a category by providing its ID and the data to update.
curl -X PUT -H 'Content-Type:application/json' http://localhost:5272/api/categories/{id} -d '{"name":"string","description":"string","weight":0}'
{
"id": "string",
"createdAt": "string",
"updatedAt": "string",
"name": "string",
"description": "string",
"weight": 0
}
Hard-deletes a category by its ID.
curl -X DELETE http://localhost:5272/api/categories/{id}
{
"id": "string",
"createdAt": "string",
"updatedAt": "string",
"name": "string",
"description": "string",
"weight": 0
}
Returns the information of a single task by its ID.
curl -X GET http://localhost:5272/api/tasks/{id}
{
"id": "string",
"createdAt": "string",
"updatedAt": "string",
"name": "string",
"description": "string",
"priority": 0,
"categoryId": "string",
"shortDescription": "string"
}
Returns the tasks.
curl -X GET http://localhost:5272/api/tasks
[
{
"id": "string",
"createdAt": "string",
"updatedAt": "string",
"name": "string",
"description": "string",
"priority": 0,
"categoryId": "string",
"shortDescription": "string"
}
]
Creates a new task.
curl -X POST -H 'Content-Type:application/json' http://localhost:5272/api/tasks -d '{"name":"string","description":"string","categoryId":"string","priority":0}'
{
"id": "string",
"createdAt": "string",
"updatedAt": "string",
"name": "string",
"description": "string",
"priority": 0,
"categoryId": "string",
"shortDescription": "string"
}
Updates a task by providing its ID and the data to update.
curl -X PUT -H 'Content-Type:application/json' http://localhost:5272/api/tasks/{id} -d '{"name":"string","description":"string","categoryId":"string","priority":0}'
{
"id": "string",
"createdAt": "string",
"updatedAt": "string",
"name": "string",
"description": "string",
"priority": 0,
"categoryId": "string",
"shortDescription": "string"
}
Hard-deletes a task by its ID.
curl -X DELETE http://localhost:5272/api/tasks/{id}
{
"id": "string",
"createdAt": "string",
"updatedAt": "string",
"name": "string",
"description": "string",
"priority": 0,
"categoryId": "string",
"shortDescription": "string"
}