Idea of the project: if someone wants to order a project development, here you can send an application.
Imports System.Configuration
Imports System.IO
Imports Newtonsoft.Json
Public Class VehicleService
Implements IVehicleService
Public Sub CreateVehicle(vehicleInfo As VehicleInfo)
File.WriteAllText($"{ConfigurationManager.AppSettings("DataFolder")}{vehicleInfo.Number}.json", JsonConvert.SerializeObject(vehicleInfo))
End Sub
Private Sub IVehicleService_CreateVehicle(vehicleInfo As VehicleInfo) Implements IVehicleService.CreateVehicle
Throw New NotImplementedException()
End Sub
Public Function IsVehicleExists(number As String) As Boolean
If String.IsNullOrWhiteSpace(number) Then
Throw New NullReferenceException
End If
Return File.Exists($"{ConfigurationManager.AppSettings("DataFolder")}{number}.json")
End Function
Public Function GetVehiclesList() As List(Of String)
Dim items As New List(Of String)
Dim dirPath = ConfigurationManager.AppSettings("DataFolder")
If Directory.Exists(dirPath)
Dim dirInfo As New DirectoryInfo(dirPath)
Dim files As FileInfo() = dirInfo.GetFiles("*.json")
For Each fileInfo In files
items.Add(fileInfo.Name.Replace(".json", ""))
Next
End If
Return items
End Function
Public Function ReadVehicleData(number As String) As String
Dim vehicleData As String = ""
If IsVehicleExists(number) Then
Dim fileName As String = $"{ConfigurationManager.AppSettings("DataFolder")}{number}.json"
vehicleData = File.ReadAllText(fileName)
End If
Return vehicleData
End Function
Private Function IVehicleService_IsVehicleExists(number As String) As Boolean Implements IVehicleService.IsVehicleExists
Throw New NotImplementedException()
End Function
Private Function IVehicleService_GetVehiclesList() As List(Of String) Implements IVehicleService.GetVehiclesList
Throw New NotImplementedException()
End Function
Private Function IVehicleService_ReadVehicleData(number As String) As String Implements IVehicleService.ReadVehicleData
Throw New NotImplementedException()
End Function
End Class