A small school-based project with ASP.net Core to model telemetry data for cars and access them via a REST-API. CRUD-Razor Page Scaffolds are used to display and modify the active state of used Local-DB.
I created this repository to help out my class mates as some are struggling a little bit with ASP.net.
Alternatively, you can override the "connectionString" in the appsettings.json File to use a diffrent relational Database.
The access is modelled with a 1:n 3NF relationship using the Entity Framework. Furthermore, the NuGet-Package EntityFrameworkCore.Triggers is used to set the ModifiedAt and the CreatedAt timestamps.
The default path for the API is /api/cars.
For most request methods, an id can be specified as the most specific path of the route: /api/cars/id
Example: GET http://localhost:51648/api/cars
[
{
"carId": 2,
"name": "Hallo Welt2",
"typ": 0,
"telemetryData": [],
"createdAt": "2020-10-16T11:02:09.2220521",
"modifiedAt": "2020-10-16T11:02:09.2220521"
}
]Example: GET http://localhost:51648/api/cars/2
{
"carId": 2,
"name": "Hallo Welt2",
"typ": 0,
"telemetryData": [],
"createdAt": "2020-10-16T11:02:09.2220521",
"modifiedAt": "2020-10-16T11:02:09.2220521"
}Example: POST http://localhost:51648/api/cars/
Request Body:
{
"name": "SomeRandomCar",
"typ": 0,
"telemetryData": []
}Response:
{
"carId": 3,
"name": "SomeRandomCar",
"typ": 0,
"telemetryData": [],
"createdAt": "2020-10-23T11:39:08.8043839+02:00",
"modifiedAt": "2020-10-23T11:39:08.8043839+02:00"
}Example: http://localhost:51648/api/cars/3 Request:
{
"name": "SomeRandomCar2",
"typ": 0,
"telemetryData": []
}Example: http://localhost:51648/api/cars/3
Response:
{
"carId": 3,
"name": "SomeRandomCar2",
"typ": 0,
"telemetryData": [],
"createdAt": "2020-10-23T11:39:08.8043839",
"modifiedAt": "2020-10-23T11:47:04.1889731"
}The index page:
Create a car:
View the details of a car:
Show telemetry data:
Open the project in visual studio and type "Update-Database" in the PackageManager-Console.