Skip to content

abhiroop43/fleetmgmt-backend

Repository files navigation

Fleet Management System Backend

Fleet Management API

Backend Web API for the Fleet Management System.

Uses ASP.NET Core v3 and IdentityServer4 for authentication.

  1. Run the IdentityServer first, then the backend server.

  2. 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.

  3. 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.

  4. Navigate to the web server directory FleetMgmt.Web and run the command dotnet run

  5. 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" }

  6. 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.

Updating from a previous version

If updating from a previous version, first create a new migration, to handle the breaking changes introduced by EF Core update.

  1. 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

  1. 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\

  1. Now navigate to the web server directory FleetMgmt.Web and run the command dotnet run