Merge pull request #1205 from hargata/Hargata/1204

add API endpoint to force recalculate all distance
This commit is contained in:
Hargata Softworks 2026-01-11 10:36:32 -07:00 committed by GitHub
commit 7f9eabb8ad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 29 additions and 0 deletions

View File

@ -21,6 +21,21 @@ namespace CarCareTracker.Controllers
var result = _vehicleLogic.GetMaxMileage(vehicleId); var result = _vehicleLogic.GetMaxMileage(vehicleId);
return Json(result); return Json(result);
} }
[TypeFilter(typeof(CollaboratorFilter), Arguments = new object[] { false, true, HouseholdPermission.Edit })]
[HttpPut]
[Route("/api/vehicle/odometerrecords/recalculate")]
public IActionResult RecalculateDistance(int vehicleId)
{
var result = _odometerRecordDataAccess.GetOdometerRecordsByVehicleId(vehicleId);
result = _odometerLogic.AutoConvertOdometerRecord(result);
if (result.Any())
{
return Json(OperationResponse.Succeed($"Odometer Records Adjusted({result.Count()})"));
} else
{
return Json(OperationResponse.Failed());
}
}
[HttpGet] [HttpGet]
[Route("/api/vehicle/odometerrecords/all")] [Route("/api/vehicle/odometerrecords/all")]
public IActionResult AllOdometerRecords(MethodParameter parameters) public IActionResult AllOdometerRecords(MethodParameter parameters)

View File

@ -242,6 +242,20 @@
], ],
"equipmentRecordId":"" "equipmentRecordId":""
} }
},
{
"path":"/api/vehicle/odometerrecords/recalculate",
"description":"Recalculate Odometer Record distance for a vehicle in user's garage",
"methodType":2,
"queryParams":[
{
"name":"vehicleId",
"description":"Id of the vehicle",
"required":true
}
],
"hasBody":false,
"bodySample":null
}, },
{ {
"path":"/api/vehicle/odometerrecords/delete", "path":"/api/vehicle/odometerrecords/delete",