rafadestri / AstoundSports

Repository for Astound chalenge

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Astound Sports

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.

Sports

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 }' image

Get All Sports curl --location --request GET 'https://localhost:5001/api/sports' image

Get a given sport curl --location --request GET 'https://localhost:5001/api/sports/{sportId}' image

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 }' image

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" } ]' image

Delete a sport curl --location --request DELETE 'https://localhost:5001/api/sports/{sportId}' image

Athletes

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" }' image

Get All Athletes curl --location --request GET 'https://localhost:5001/api/athletes' image

Get a given athlete detail curl --location --request GET 'https://localhost:5001/api/athletes/{athleteId}' image

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 }' image

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" } ]' image

Delete an athlete curl --location --request DELETE 'https://localhost:5001/api/athletes/{athleteId}' image

Get burnt calories for a given athlete on a given sport curl --location --request GET 'https://localhost:5001/api/athletes/{athleteId}/burntCalories/{sportId}' image

check if a given athlete can practice a given sport curl --location --request GET 'https://localhost:5001/api/athletes/{athleteId}/canPractice/{sportId}' image

About

Repository for Astound chalenge


Languages

Language:C# 100.0%