@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"); } }
@($"# of Gas Records: {Model.GasRecords.Count()}") @if (Model.GasRecords.Where(x => x.MilesPerGallon > 0).Any()) { @($"Average Fuel Economy: {gasHelper.GetAverageGasMileage(Model.GasRecords, useMPG)}") if (useMPG) { @($"Min Fuel Economy: {Model.GasRecords.Where(y => y.MilesPerGallon > 0)?.Min(x => x.MilesPerGallon).ToString("F") ?? "0"}") @($"Max Fuel Economy: {Model.GasRecords.Max(x => x.MilesPerGallon).ToString("F") ?? "0"}") } else { @($"Min Fuel Economy: {Model.GasRecords.Max(x => x.MilesPerGallon).ToString("F") ?? "0"}") @($"Max Fuel Economy: {Model.GasRecords.Where(y => y.MilesPerGallon > 0)?.Min(x => x.MilesPerGallon).ToString("F") ?? "0"}") } } @($"Total Fuel Consumed: {Model.GasRecords.Sum(x => x.Gallons).ToString("F")}") @($"Total Cost: {Model.GasRecords.Sum(x => x.Cost).ToString(gasCostFormat)}")
@if (enableCsvImports) {
} else { }
@foreach (GasRecordViewModel gasRecord in Model.GasRecords) { }
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))