fix user preferrred unit in vehicle consolidated report.

This commit is contained in:
DESKTOP-T0O5CDB\DESK-555BD
2024-01-31 17:43:38 -07:00
parent 338a8426b2
commit 3a1836ef84
3 changed files with 38 additions and 24 deletions

View File

@@ -140,5 +140,28 @@ namespace CarCareTracker.Helper
Notes = input.Notes
};
}
public static string GetFuelEconomyUnit(bool useKwh, bool useHours, bool useMPG, bool useUKMPG)
{
string fuelEconomyUnit;
if (useKwh)
{
var distanceUnit = useHours ? "h" : (useMPG ? "mi." : "km");
fuelEconomyUnit = useMPG ? $"{distanceUnit}/kWh" : $"kWh/100{distanceUnit}";
}
else if (useMPG && useUKMPG)
{
fuelEconomyUnit = useHours ? "h/g" : "mpg";
}
else if (useUKMPG)
{
fuelEconomyUnit = useHours ? "l/100h" : "l/100mi.";
}
else
{
fuelEconomyUnit = useHours ? (useMPG ? "h/g" : "l/100h") : (useMPG ? "mpg" : "l/100km");
}
return fuelEconomyUnit;
}
}
}