diff --git a/Controllers/HomeController.cs b/Controllers/HomeController.cs index c406da6..d309c9c 100644 --- a/Controllers/HomeController.cs +++ b/Controllers/HomeController.cs @@ -93,7 +93,7 @@ namespace CarCareTracker.Controllers var maxMileage = _vehicleLogic.GetMaxMileage(vehicleRecords); var minMileage = _vehicleLogic.GetMinMileage(vehicleRecords); var totalDistance = maxMileage - minMileage; - vehicleVM.CostPerMile = vehicleTotalCost / totalDistance; + vehicleVM.CostPerMile = totalDistance != default ? vehicleTotalCost / totalDistance : 0.00M; vehicleVM.DistanceUnit = distanceUnit; } if (vehicleVM.DashboardMetrics.Contains(DashboardMetric.TotalCost))