@inject IConfiguration Configuration @{ 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
@($"# of Gas Records: {Model.Count()}") @if (Model.Where(x=>x.MilesPerGallon > 0).Any()) { @($"Average Fuel Economy: {Model.Where(y => y.MilesPerGallon > 0)?.Average(x => x.MilesPerGallon).ToString("F") ?? "0"}") @($"Min Fuel Economy: {Model.Where(y => y.MilesPerGallon > 0)?.Min(x => x.MilesPerGallon).ToString("F") ?? "0"}") @($"Max Fuel Economy: {Model.Max(x => x.MilesPerGallon).ToString("F") ?? "0"}") } @($"Total Fuel Consumed: {Model.Sum(x=>x.Gallons).ToString("F")}") @($"Total Cost: {Model.Sum(x => x.Cost).ToString("C3")}")
@if (enableCsvImports) {
} else { }
@foreach (GasRecordViewModel gasRecord in Model) { }
Date Refueled Odometer(@(useMPG ? "mi." : "km")) Consumption(@(consumptionUnit)) Fuel Economy(@(fuelEconomyUnit)) Cost Unit Cost
@gasRecord.Date @gasRecord.Mileage @gasRecord.Gallons.ToString("F") @(gasRecord.MilesPerGallon == 0 ? "---" : gasRecord.MilesPerGallon.ToString("F")) @gasRecord.Cost.ToString("C3") @gasRecord.CostPerGallon.ToString("C3")