@using CarCareTracker.Helper @inject IConfigHelper config @inject IGasHelper gasHelper @inject ITranslationHelper translator @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 useThreeDecimalsConsumption = userConfig.UseThreeDecimalGasConsumption; var gasCostFormat = useThreeDecimals ? "C3" : "C2"; var gasConsumptionFormat = useThreeDecimalsConsumption ? "F3" : "F2"; var userLanguage = userConfig.UserLanguage; var useKwh = Model.UseKwh; var useHours = Model.UseHours; var recordTags = Model.GasRecords.SelectMany(x => x.Tags).Distinct(); 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"); } var extraFields = new List(); if (userConfig.EnableExtraFieldColumns) { extraFields = Model.GasRecords.SelectMany(x => x.ExtraFields).Select(y => y.Name).Distinct().ToList(); } var userColumnPreferences = userConfig.UserColumnPreferences.Where(x => x.Tab == ImportMode.GasRecord); }
@($"{translator.Translate(userLanguage, "# of Gas Records")}: {Model.GasRecords.Count()}") @if (Model.GasRecords.Where(x => x.MilesPerGallon > 0).Any()) { @($"{translator.Translate(userLanguage, "Average Fuel Economy")}: {gasHelper.GetAverageGasMileage(Model.GasRecords, useMPG)}") if (useMPG) { @($"{translator.Translate(userLanguage, "Min Fuel Economy")}: {Model.GasRecords.Where(y => y.MilesPerGallon > 0)?.Min(x => x.MilesPerGallon).ToString("F") ?? "0"}") @($"{translator.Translate(userLanguage, "Max Fuel Economy")}: {Model.GasRecords.Max(x => x.MilesPerGallon).ToString("F") ?? "0"}") } else { @($"{translator.Translate(userLanguage, "Min Fuel Economy")}: {Model.GasRecords.Max(x => x.MilesPerGallon).ToString("F") ?? "0"}") @($"{translator.Translate(userLanguage, "Max Fuel Economy")}: {Model.GasRecords.Where(y => y.MilesPerGallon > 0)?.Min(x => x.MilesPerGallon).ToString("F") ?? "0"}") } @($"{translator.Translate(userLanguage, "Total Distance")}: {Model.GasRecords.Sum(x => x.DeltaMileage).ToString() ?? "0"} {distanceUnit}") } @($"{translator.Translate(userLanguage, "Total Fuel Consumed")}: {Model.GasRecords.Sum(x => x.Gallons).ToString("F")}") @($"{translator.Translate(userLanguage, "Total Cost")}: {Model.GasRecords.Sum(x => x.Cost).ToString(gasCostFormat)}") @foreach (string recordTag in recordTags) { @recordTag } @foreach (string recordTag in recordTags) { }
@if (enableCsvImports) {
} else { }
@foreach (string extraFieldColumn in extraFields) { } @foreach (GasRecordViewModel gasRecord in Model.GasRecords) { @foreach (string extraFieldColumn in extraFields) { } }
@translator.Translate(userLanguage, "Date Refueled") @($"{translator.Translate(userLanguage, "Odometer")}({distanceUnit})") @($"Δ({distanceUnit})") @($"{translator.Translate(userLanguage, "Consumption")}({consumptionUnit})") @($"{@translator.Translate(userLanguage, "Fuel Economy")}({fuelEconomyUnit})") @translator.Translate(userLanguage, "Cost") @translator.Translate(userLanguage, "Unit Cost")
@gasRecord.Date @(gasRecord.Mileage == default ? "---" : gasRecord.Mileage.ToString()) @(gasRecord.DeltaMileage == default ? "---" : gasRecord.DeltaMileage) @gasRecord.Gallons.ToString(gasConsumptionFormat) @(gasRecord.MilesPerGallon == 0 ? "---" : gasRecord.MilesPerGallon.ToString("F")) @((hideZero && gasRecord.Cost == default) ? "---" : gasRecord.Cost.ToString(gasCostFormat)) @((hideZero && gasRecord.CostPerGallon == default) ? "---" : gasRecord.CostPerGallon.ToString(gasCostFormat))
@StaticHelper.ReportNote
@if (userColumnPreferences.Any()) { @await Html.PartialAsync("_UserColumnPreferences", userColumnPreferences) }