handle 0 MPG and styling bug fixes.

This commit is contained in:
DESKTOP-T0O5CDB\DESK-555BD
2024-01-12 14:54:42 -07:00
parent a06bdbff88
commit cb73be0e43
4 changed files with 17 additions and 12 deletions

View File

@@ -697,7 +697,12 @@ namespace CarCareTracker.Controllers
bool useUKMPG = bool.Parse(_config[nameof(UserConfig.UseUKMPG)]);
vehicleHistory.TotalGasCost = gasRecords.Sum(x => x.Cost);
vehicleHistory.TotalCost = serviceRecords.Sum(x => x.Cost) + repairRecords.Sum(x => x.Cost) + upgradeRecords.Sum(x => x.Cost) + taxRecords.Sum(x => x.Cost);
var averageMPG = _gasHelper.GetGasRecordViewModels(gasRecords, useMPG, useUKMPG).Average(x => x.MilesPerGallon);
var averageMPG = 0.00M;
var gasViewModels = _gasHelper.GetGasRecordViewModels(gasRecords, useMPG, useUKMPG);
if (gasViewModels.Any())
{
averageMPG = gasViewModels.Average(x => x.MilesPerGallon);
}
vehicleHistory.MPG = averageMPG;
//insert servicerecords
reportData.AddRange(serviceRecords.Select(x => new GenericReportModel