Backend Web API for the Fleet Management System.
Uses ASP.NET Core v3 and IdentityServer4 for authentication.
-
Run the IdentityServer first, then the backend server.
-
To run the identity server navigate to the FleetMgmt.IdentityServer directory and run the commands:
dotnet ef database update --context ConfigurationDbContext
dotnet ef database update --context ApplicationDbContext
dotnet run /seed
The seed flag updates the database with the clients, the Identity resources and the API resources.
-
Navigate to the Data directory FleetMgmt.Web and run the command:
dotnet ef database update --context FmDbContext
This will populate the database with the tables.
-
Navigate to the web server directory FleetMgmt.Web and run the command dotnet run
-
To register the user, you may use the following request:
URL: http://localhost:5000/Account/RegisterUser
Request Type: POST
Sample Request:
{ "email": "jane.doe@example.com", "password": "MySecuredPassword@123", "confirmPassword": "MySecuredPassword@123" }
-
To get the login token, you may use the following request:
URL: http://localhost:5000/connect/token
Request Type: POST
Headers: {"Content-Type": "multipart/form-data"}
Request Body:
client_id:ro.client client_secret:secret grant_type:password username:john.doe@example.com password:Abcd@1234 scope:fleetMgmt
Please Note: This solution (both the Web API and the IdentityServer) uses SQL Local DB. You may change the connection string from the appsettings.json file.
If updating from a previous version, first create a new migration, to handle the breaking changes introduced by EF Core update.
- Navigate to the FleetMgmt.IdentityServer directory and run the commands:
dotnet ef migrations add FrameworkUpdate
dotnet ef migrations add FrameworkUpdate --context ConfigurationDbContext
Now, you may seed the database again using:
dotnet run /seed
- Navigate to the Data directory FleetMgmt.Data and run the commands:
dotnet ef migrations add FrameworkUpdateWeb --context FmDbContext -s ..\FleetMgmt.Web\
dotnet ef database update --context FmDbContext -s ..\FleetMgmt.Web\
- Now navigate to the web server directory FleetMgmt.Web and run the command dotnet run