Install global EntityFramework tool
dotnet tool install --global dotnet-ef
First we need to set up you're local environment and make sure you're database is up to date.
Open the command line in the root directory (wherever you've created the git repo)
Run the following
docker-compose up -d
N.B. This will set up a local postgres database.
Now run
dotnet ef database update --project src/Persistence --startup-project src/WebAPI
N.B. This will update the database schema to match the current database object in the dotnet project
From the root directory run the following commands
cd src/WebAPI
dotnet run
This moves the context of the command line to the WebAPI src code and starts the WebAPI with the URL https://localhost:5001
If you navigate to https://localhost:5001/swagger you can access the swagger documentation related to the API
If you look at doc/TeaPickerActivityDiagram.png
you can see the activity diagram for the TeaPickerProduct.
But a general case is create as many users as you want:
POST /v1/Users
{
"lastName": "string",
"firstName": "string"
}
Don't forget to add a Order to that user:
POST /v1/Users/{userId}/Order
{
"name": "string",
"type": "string",
"additionalSpecification": {
"additionalProp1": "string",
"additionalProp2": "string",
"additionalProp3": "string"
}
}
N.B You can add specification of how to make your drink with the additionalSpecification object
Once you've created all you're users now you can create your order. The DrinkPicker uses a patented algorithm to calculate the most fair person to pick to make the tea.
POST /v1/DrinkRun
{
"participants": [
{
"userId": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
},
{
"userId": "6d549882-185b-4a9d-a88d-54a3f2e079a3"
}
]
}
If you update or create any new DbModels we need to update the EF migration script. The migration script will generate the sql needed to change the schema.
Run
dotnet ef migrations add ${TheNameOfTheNewMigrationScript} --project src/Persistence --startup-project src/WebAPI