@using CarCareTracker.Helper @inject IConfigHelper config @inject IGasHelper gasHelper @model GasRecordViewModelContainer @{ var userConfig = config.GetUserConfig(User); var enableCsvImports = userConfig.EnableCsvImports; var useMPG = userConfig.UseMPG; var useUKMPG = userConfig.UseUKMPG; var hideZero = userConfig.HideZero; var useThreeDecimals = userConfig.UseThreeDecimalGasCost; var gasCostFormat = useThreeDecimals ? "C3" : "C2"; var useKwh = Model.UseKwh; var useHours = Model.UseHours; string preferredFuelEconomyUnit = userConfig.PreferredGasMileageUnit; string preferredGasUnit = userConfig.PreferredGasUnit; string consumptionUnit; string fuelEconomyUnit; string distanceUnit = useHours ? "h" : (useMPG ? "mi." : "km"); if (useKwh) { consumptionUnit = "kWh"; fuelEconomyUnit = useMPG ? $"{distanceUnit}/kWh" : $"kWh/100{distanceUnit}"; } else if (useMPG && useUKMPG) { consumptionUnit = "imp gal"; fuelEconomyUnit = useHours ? "h/g" : "mpg"; } else if (useUKMPG) { fuelEconomyUnit = useHours ? "l/100h" : "l/100mi."; consumptionUnit = "l"; distanceUnit = useHours ? "h" : "mi."; } else { consumptionUnit = useMPG ? "US gal" : "l"; fuelEconomyUnit = useHours ? (useMPG ? "h/g" : "l/100h") : (useMPG ? "mpg" : "l/100km"); } }
| Date Refueled | Odometer(@(distanceUnit)) | Consumption(@(consumptionUnit)) | Fuel Economy(@(fuelEconomyUnit)) | Cost | Unit Cost |
|---|---|---|---|---|---|
| @gasRecord.Date | @gasRecord.Mileage | @gasRecord.Gallons.ToString("F") | @(gasRecord.MilesPerGallon == 0 ? "---" : gasRecord.MilesPerGallon.ToString("F")) | @((hideZero && gasRecord.Cost == default) ? "---" : gasRecord.Cost.ToString(gasCostFormat)) | @((hideZero && gasRecord.CostPerGallon == default) ? "---" : gasRecord.CostPerGallon.ToString(gasCostFormat)) |