Upload files to "/"
This commit is contained in:
1 parent
6807c5a941
commit
1aed1b2dbb
1 file changed
+52
-17
+52
-17
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@@ -28,7 +28,7 @@ class StarProtect
|
|||||||
const string fp_data = "uwdata.json";
|
const string fp_data = "uwdata.json";
|
||||||
|
|
||||||
const string fp_vehicle = "vehicles.json";
|
const string fp_vehicle = "vehicles.json";
|
||||||
|
const string fp_pdata = "policydata.json";
|
||||||
|
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
@@ -427,19 +427,21 @@ class StarProtect
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<VehicleInsurance> vehicleList = GetVehicles(uwid);
|
List<VehicleInsurance> vehicleList = GetVehicles(uwid);
|
||||||
if (vehicleList.Count == 0)
|
if (vehicleList.Count == 0)
|
||||||
{
|
{
|
||||||
Warn($"No vehicles registered under underwriter {uwid}");
|
Warn($"No vehicles registered under underwriter {uwid}");
|
||||||
Thread.Sleep(1500);
|
Thread.Sleep(1500);
|
||||||
AdminHome();
|
AdminHome();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
foreach (VehicleInsurance v in vehicleList)
|
foreach (VehicleInsurance v in vehicleList)
|
||||||
{
|
{
|
||||||
DisplayVehicle(v);
|
DisplayVehicle(v);
|
||||||
|
}
|
||||||
}
|
Prompt("Press any key to return...");
|
||||||
|
Console.ReadKey();
|
||||||
|
AdminHome();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -527,7 +529,12 @@ class StarProtect
|
|||||||
{
|
{
|
||||||
Console.Clear();
|
Console.Clear();
|
||||||
PrintHeading("[ Create New Vehicle Insurance ]", boldCyan);
|
PrintHeading("[ Create New Vehicle Insurance ]", boldCyan);
|
||||||
var vehicle = new VehicleInsurance { policyNo = uw.ID };
|
IncrementPolicyData();
|
||||||
|
PolicyData pd = GetPolicyData();
|
||||||
|
var vehicle = new VehicleInsurance { policyNo = pd.numPol };
|
||||||
|
vehicle.uwId = uw.ID;
|
||||||
|
DrawBox($"Policy #{vehicle.policyNo}", boldCyan);
|
||||||
|
ResetColor();
|
||||||
Prompt("Enter vehicle number: ");
|
Prompt("Enter vehicle number: ");
|
||||||
vehicle.vehicleNo = Console.ReadLine();
|
vehicle.vehicleNo = Console.ReadLine();
|
||||||
Prompt("Enter vehicle type: ");
|
Prompt("Enter vehicle type: ");
|
||||||
@@ -838,7 +845,7 @@ class StarProtect
|
|||||||
if (File.Exists(fp_vehicle))
|
if (File.Exists(fp_vehicle))
|
||||||
{
|
{
|
||||||
vehicleList = JsonSerializer.Deserialize<List<VehicleInsurance>>(File.ReadAllText(fp_vehicle));
|
vehicleList = JsonSerializer.Deserialize<List<VehicleInsurance>>(File.ReadAllText(fp_vehicle));
|
||||||
return vehicleList.Where(v => v.policyNo == uwid).ToList();
|
return vehicleList.Where(v => v.uwId == uwid).ToList();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -862,6 +869,28 @@ class StarProtect
|
|||||||
File.WriteAllText(fp_uw, jsonString);
|
File.WriteAllText(fp_uw, jsonString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void IncrementPolicyData()
|
||||||
|
{
|
||||||
|
PolicyData pd = GetPolicyData();
|
||||||
|
pd.numPol += 1;
|
||||||
|
string jsonString = JsonSerializer.Serialize<PolicyData>(pd);
|
||||||
|
File.WriteAllText(fp_pdata, jsonString);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static PolicyData GetPolicyData()
|
||||||
|
{
|
||||||
|
PolicyData pd;
|
||||||
|
if (File.Exists(fp_pdata))
|
||||||
|
{
|
||||||
|
pd = JsonSerializer.Deserialize<PolicyData>(File.ReadAllText(fp_pdata));
|
||||||
|
return pd;
|
||||||
|
}
|
||||||
|
pd = new PolicyData { numPol = 0 };
|
||||||
|
string jsonString = JsonSerializer.Serialize<PolicyData>(pd);
|
||||||
|
File.WriteAllText(fp_pdata, jsonString);
|
||||||
|
return pd;
|
||||||
|
}
|
||||||
|
|
||||||
public static void DelUw(int id)
|
public static void DelUw(int id)
|
||||||
{
|
{
|
||||||
List<Underwriter> uwList = GetUw();
|
List<Underwriter> uwList = GetUw();
|
||||||
@@ -954,6 +983,7 @@ public class VehicleInsurance
|
|||||||
public string type { get; set; }
|
public string type { get; set; }
|
||||||
public DateOnly fromDate { get; set; }
|
public DateOnly fromDate { get; set; }
|
||||||
public DateOnly toDate { get; set; }
|
public DateOnly toDate { get; set; }
|
||||||
|
public int uwId { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
// store number of underwriters who exist, for auto ID generation
|
// store number of underwriters who exist, for auto ID generation
|
||||||
@@ -961,3 +991,8 @@ public class UwData
|
|||||||
{
|
{
|
||||||
public int numUw { get; set; }
|
public int numUw { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class PolicyData
|
||||||
|
{
|
||||||
|
public int numPol { get; set; }
|
||||||
|
}
|
||||||
Reference in new issue
Block a user