@inject IConfiguration Configuration @model GasRecordViewModelContainer @{ var enableCsvImports = bool.Parse(Configuration[nameof(UserConfig.EnableCsvImports)]); var useMPG = bool.Parse(Configuration[nameof(UserConfig.UseMPG)]); var useUKMPG = bool.Parse(Configuration[nameof(UserConfig.UseUKMPG)]); var hideZero = bool.Parse(Configuration[nameof(UserConfig.HideZero)]); var useKwh = Model.UseKwh; string consumptionUnit; string fuelEconomyUnit; string distanceUnit = useMPG ? "mi." : "km"; if (useKwh) { consumptionUnit = "kWh"; fuelEconomyUnit = useMPG ? "mi./kWh" : "kWh/100km"; } else if (useMPG && useUKMPG) { consumptionUnit = "imp gal"; fuelEconomyUnit = "mpg"; } else if (useUKMPG) { fuelEconomyUnit = "l/100mi."; consumptionUnit = "l"; distanceUnit = "mi."; } else { consumptionUnit = useMPG ? "US gal" : "l"; fuelEconomyUnit = useMPG ? "mpg" : "l/100km"; } }
@($"# of Gas Records: {Model.GasRecords.Count()}") @if (Model.GasRecords.Where(x => x.MilesPerGallon > 0).Any()) { @($"Average Fuel Economy: {Model.GasRecords.Where(y => y.MilesPerGallon > 0)?.Average(x => x.MilesPerGallon).ToString("F") ?? "0"}") @($"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"}") } @($"Total Fuel Consumed: {Model.GasRecords.Sum(x => x.Gallons).ToString("F")}") @($"Total Cost: {Model.GasRecords.Sum(x => x.Cost).ToString("C3")}")
@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("C3")) @((hideZero && gasRecord.CostPerGallon == default) ? "---" : gasRecord.CostPerGallon.ToString("C3"))