Repository for Astound chalenge
In this project I tried to accomplish all the request for the chalenge. I made this based on an exercise from a book I'm reading. There are some considerations and things I would make different, with more time, such as:
- Move the logic code from controllers to a business layer
- Add unit tests
- Move validation logic from entities to DTOs
- Add Open API documentation
- Improve the sports with an undetermined duration, like VolleyBall
- Add logic to handle subtypes of sport, like marathon.
On the screenshots below you can check the request/response from postman on all endpoints.
Create a sport curl --location --request POST 'https://localhost:5001/api/sports' \ --header 'Content-Type: application/json' \ --data-raw '{ "name": "Swimming", "caloriesBurntByMinute": 40, "duration": 0, "numberOfPlayers": 1 }'
Get All Sports curl --location --request GET 'https://localhost:5001/api/sports'
Get a given sport curl --location --request GET 'https://localhost:5001/api/sports/{sportId}'
Update a whole sport with PUT curl --location --request PUT 'https://localhost:5001/api/sports/{sportId}' \ --header 'Content-Type: application/json' \ --data-raw '{ "name": "Female VoleyBall", "caloriesBurntByMinute": 15, "duration": 0, "numberOfPlayers": 12 }'
Update a single sport property with PATCH curl --location --request PATCH 'https://localhost:5001/api/sports/{sportId}' \ --header 'Content-Type: application/json' \ --data-raw '[ { "op" : "replace", "path": "/numberOfPlayers", "value" : "12" } ]'
Delete a sport curl --location --request DELETE 'https://localhost:5001/api/sports/{sportId}'
Create an athlete curl --location --request POST 'https://localhost:5001/api/athletes' \ --header 'Content-Type: application/json' \ --data-raw '{ "name": "Rafael", "surname": "Destri", "maximumCalories": 100, "age": 40, "country": "BR" }'
Get All Athletes curl --location --request GET 'https://localhost:5001/api/athletes'
Get a given athlete detail curl --location --request GET 'https://localhost:5001/api/athletes/{athleteId}'
Update a whole sport with PUT curl --location --request PUT 'https://localhost:5001/api/athletes/{athleteId}' \ --header 'Content-Type: application/json' \ --data-raw ' { "age": 30, "burntCalories": 0, "country": "BR", "name": "Audrey", "surname" : "Audrey", "id": "f049f5a6-e1f4-4300-8f54-a44b63831a37", "maximumCalories": 1000 }'
Update a single athlete property with PATCH curl --location --request PATCH 'https://localhost:5001/api/athletes/{athleteId}' \ --header 'Content-Type: application/json' \ --data-raw '[ { "op" : "replace", "path": "/maximumCalories", "value" : "250" } ]'
Delete an athlete curl --location --request DELETE 'https://localhost:5001/api/athletes/{athleteId}'
Get burnt calories for a given athlete on a given sport curl --location --request GET 'https://localhost:5001/api/athletes/{athleteId}/burntCalories/{sportId}'
check if a given athlete can practice a given sport curl --location --request GET 'https://localhost:5001/api/athletes/{athleteId}/canPractice/{sportId}'