Special Project #13 for Epicodus, 7 April 2023
a martial arts gym student tracking api to be integrated with a gym client
first, make sure that you have the dotnet sdk and dotnet entity framework tool installed.
dotnet tool install --global dotnet-ef --version 6.0.0
- clone this repository to the directory of your choosing.
git clone https://github.com/John-Dig/StudentsTracker.Solution
- navigate to the StudentsTracker.Solution directory(folder).
cd StudentsTracker.Solution/TrackerApi
- create two new files in that directory
appsettings.json
andappsettings.Development.json
.
touch appsettings.json appsettings.Development.json
- in appsettings, add the information below replacing database name, uid, pwd to suit your own situation.
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"DefaultConnection": "Server=localhost;Port=3306;database=NAME_OF_YOUR_CHOOSING;uid=YOUR_USER_NAME;pwd=YOUR_PASSWORD;"
}
}
- in appsettings.Development.json add the following.
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Trace",
"Microsoft.AspNetCore": "Information",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}
- next set up your local database with the following dotnet entity framework command
dotnet ef database update
- you are ready to start the api server. this will start the server in production mode. if you are going to develop it further, run the following without the --launch-profile
dotnet watch run --launch-profile "TrackerApi-Production"
- use your favorite program to make api calls (eg, postman, curl on the command line, or with swagger). swagger can be found at http://localhost:5288/swagger
GET http://localhost:5250/api/students/
GET http://localhost:5250/api/students/{id}
POST http://localhost:5250/api/students/
PUT http://localhost:5250/api/students/{id}
DELETE http://localhost:5250/api/students/{id}
GET http://localhost:5250/api/promotions/
GET http://localhost:5250/api/promotions/{id}
POST http://localhost:5250/api/promotions/
PUT http://localhost:5250/api/promotions/{id}
DELETE http://localhost:5250/api/promotions/{id}
GET http://localhost:5250/api/coaches/
GET http://localhost:5250/api/coaches/{id}
POST http://localhost:5250/api/coaches/
PUT http://localhost:5250/api/coaches/{id}
DELETE http://localhost:5250/api/coaches/{id}
note: {id}
is a variable and it should be replaced with the id number of the animal you want to GET, PUT, or DELETE.
a body is required for the post to be successful. remember to leave the idea at 0 for the database to auto-increment
here is an example from the coaches endpoint:
{
"coachId": 0,
"firstN": "Jimmy",
"lastN": "Carter",
"email": "[email protected]",
"phone": "555-555-5555",
"beltId": 124,
"promotions": null
}
when making a put request, you must provide the whole object, not just the value that is changing. thus:
{
"studentId": 7,
"firstN": "Funny",
"lastN": "Guy",
"email": "[email protected]",
"beltId": 114,
"dateEnrolled": "2023-04-05T16:12:55.04",
"promotions": null
}
becomes
{
"studentId": 7,
"firstN": "Buddy",
"lastN": "Guy",
"email": "[email protected]",
"beltId": 114,
"dateEnrolled": "2023-04-05T16:12:55.04",
"promotions": null
}
copyright (c) [2023] team-dont-forget-to-log-out. AKA: John Diggins and his mutable array
permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the software, and to permit persons to whom the software is furnished to do so, subject to the following conditions:
the above copyright notice and this permission notice shall be included in all copies or substantial portions of the software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.