- Vehicle Management System
git clone https://github.com/josh-asi/vms-web-api
Open VMS.sln using Visual Studio and create a VMS database via the SQL Server Object Explorer. Run the ClearData.sql script found in VMS.Infrastucture/Data/Schema to populate the tables.
Run the project VMS.Api. Swagger will open by default.
Please ensure that a database called VMS is created in (localdb)\MSSQLLocalDB. For a closer look at the schema, please look at VMS.Infrastructure/Data/Schema. Each SQL script will have the fields and field types for each table.
If there are no entities found in VMS.Infrastructure/Data/EntityFramework/Entities, to generate them* from the database entities into Entity Framework entities, in Visual Studio, select menu Tools -> NuGet Package Manger -> Package Manger Console and run the following command:
Scaffold-DbContext "Server=(localdb)\MSSQLLocalDB;Database=VMS;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Data/EntityFramework/Entities -f
To check if the connection has been configured properly, please navigate to https://localhost:5001/health once the server is running.
*Make sure that the Default project is set to VMS.Infrastructure and that Microsoft.EntityFrameworkCore.Tools is installed as a nuget package.
I have tried to implement the Ports and Adapter Pattern/Hexagonal Architecture.
- VMS.Api - .NET Core Api implementation
- VMS.Application - where the application logic lives. Mostly composed of ports/interfaces
- VMS.Domain - where the domain logic resides
- VMS.Infrastructure - various adapters/implementations of ports
Property : Type
- +Id : int
- +Type : VehicleType
- +Speed : Speed
- +Mileage : Kilometres
- +Location : Location (WIP)
- +Measurements: Measurement (WIP)
- +Truck - 1
- +Bus - 2
- -kilometresPerHour : double
- -latitude : double
- -longitude : double
- -kilometres: double
POST /api/vehicle
Adds a new vehicle.
Required Parameters:
- Type : int
- Speed : double
- Mileage: double
GET /api/vehicles
Returns all the vehicles available
GET /api/vehicle/types
Returns a list of all the vehicle types
PATCH /api/vehicle/mileage
Updates the mileage for a vehicle. It only successfully updates the mileage if it's greater than or equal to the current mileage
Required Parameters:
- VehicleId : int
- NewMileage : double
DELETE /api/vehicle/{vehicleId}
Removes the vehicle from the records
- .NET Core
- SQL Server
- EF Core
To have a look at the client implementation, please go to this link.