Learn some C#/.NET with a Web API example, trying to follow RESTful API patterns.
The project implements a gambling scenario.
- users bet on a random number between 0 and 9
- users start with an account balance of 10000
- users bet a stake within their account balance on the random number
- when users bet on the right number they earn 9 times their stake
- there are in-memory repositories for users and bets
- the user repository holds 2 users: Bob (id=1) and Alice (id=2)
- GET /bets - collection of made bets
- POST /bets - create (place) a bet
- GET /bets/{id} - get bet with a specific id
- GET /bets/{id}/result - bet result sub resource returning the outcome of a bet
- GET /users - collection of users
- GET /users/{id} - get user with a specific id
- GET /users/{id}/account - account sub resource for a user
When running the project you can open Swagger UI under /swagger
.
dotnet test
dotnet run --project bettor