Skip to content

josh-asi/vms-web-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vehicle Management System

Setup

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.

Database

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.

Architecture

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

Domain

Property : Type

Entity

  • +Id : int

Vehicle (Aggregate Root, Entity)

VehicleType (ValueObject - enum)

  • +Truck - 1
  • +Bus - 2

Speed (ValueObject)

  • -kilometresPerHour : double

Location (Entity)

Latitude (ValueObject)

  • -latitude : double

Longitude (ValueObject)

  • -longitude : double

Kilometres (ValueObject)

  • -kilometres: double

Use Cases

AddVehicle

POST /api/vehicle

Adds a new vehicle.

Required Parameters:

  • Type : int
  • Speed : double
  • Mileage: double

GetVehicles

GET /api/vehicles

Returns all the vehicles available

GetVehicleTypes

GET /api/vehicle/types

Returns a list of all the vehicle types

UpdateMileage

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

DeleteVehicle

DELETE /api/vehicle/{vehicleId}

Removes the vehicle from the records

Technologies Used

  • .NET Core
  • SQL Server
  • EF Core

Client

To have a look at the client implementation, please go to this link.

References/Inspiration

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published