added logic to overwrite consumption units with kwh

This commit is contained in:
DESKTOP-GENO133\IvanPlex
2024-01-06 09:57:08 -07:00
parent b0773f5102
commit 4543e56c61
2 changed files with 25 additions and 3 deletions

View File

@@ -2,6 +2,18 @@
@{
var enableCsvImports = bool.Parse(Configuration[nameof(UserConfig.EnableCsvImports)]);
var useMPG = bool.Parse(Configuration[nameof(UserConfig.UseMPG)]);
var useKwh = bool.Parse(Configuration[nameof(UserConfig.UsekWh)]);
string consumptionUnit;
string fuelEconomyUnit;
if (useKwh)
{
consumptionUnit = "kWh";
fuelEconomyUnit = useMPG ? "mi/kWh" : "kWh/100km";
} else
{
consumptionUnit = useMPG ? "gal" : "l";
fuelEconomyUnit = useMPG ? "mpg" : "l/100km";
}
}
@model List<GasRecordViewModel>
<div class="row">
@@ -40,8 +52,8 @@
<tr class="d-flex">
<th scope="col" class="col-2">Date Refueled</th>
<th scope="col" class="col-2">Odometer(@(useMPG ? "mi." : "km"))</th>
<th scope="col" class="col-2">Consumption(@(useMPG ? "gal" : "l"))</th>
<th scope="col" class="col-2">Fuel Economy(@(useMPG ? "mpg" : "l/100km"))</th>
<th scope="col" class="col-2">Consumption(@(consumptionUnit))</th>
<th scope="col" class="col-2">Fuel Economy(@(fuelEconomyUnit))</th>
<th scope="col" class="col-2">Cost</th>
<th scope="col" class="col-2">Unit Cost</th>
</tr>

View File

@@ -2,7 +2,17 @@
@model GasRecordInput
@{
var useMPG = bool.Parse(Configuration[nameof(UserConfig.UseMPG)]);
var useKwh = bool.Parse(Configuration[nameof(UserConfig.UsekWh)]);
var isNew = Model.Id == 0;
string consumptionUnit;
if (useKwh)
{
consumptionUnit = "kWh";
}
else
{
consumptionUnit = useMPG ? "gallons" : "liters";
}
}
<div class="modal-header">
<h5 class="modal-title">@(isNew ? "Add New Gas Record" : "Edit Gas Record")</h5>
@@ -21,7 +31,7 @@
</div>
<label for="gasRecordMileage">Odometer Reading(@(useMPG ? "miles" : "kilometers"))</label>
<input type="number" id="gasRecordMileage" class="form-control" placeholder="Odometer reading when refueled" value="@(isNew ? "" : Model.Mileage)">
<label for="gasRecordGallons">Fuel Consumption(@(useMPG ? "gallons" : "liters"))</label>
<label for="gasRecordGallons">Fuel Consumption(@(consumptionUnit))</label>
<input type="text" id="gasRecordGallons" class="form-control" placeholder="Amount of gas refueled" value="@(isNew ? "" : Model.Gallons)">
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" role="switch" id="gasIsFillToFull" checked="@Model.IsFillToFull">