Prevent decimals in odometer fields to error out.

This commit is contained in:
DESKTOP-T0O5CDB\DESK-555BD
2024-01-25 13:58:47 -07:00
parent 51ff01d2cd
commit e47c541e08
7 changed files with 11 additions and 11 deletions

View File

@@ -376,7 +376,7 @@ namespace CarCareTracker.Controllers
{ {
VehicleId = vehicleId, VehicleId = vehicleId,
Date = DateTime.Parse(importModel.Date), Date = DateTime.Parse(importModel.Date),
Mileage = int.Parse(importModel.Odometer, NumberStyles.Any), Mileage = decimal.ToInt32(decimal.Parse(importModel.Odometer, NumberStyles.Any)),
Gallons = decimal.Parse(importModel.FuelConsumed, NumberStyles.Any), Gallons = decimal.Parse(importModel.FuelConsumed, NumberStyles.Any),
Notes = string.IsNullOrWhiteSpace(importModel.Notes) ? "" : importModel.Notes Notes = string.IsNullOrWhiteSpace(importModel.Notes) ? "" : importModel.Notes
}; };
@@ -420,7 +420,7 @@ namespace CarCareTracker.Controllers
{ {
VehicleId = vehicleId, VehicleId = vehicleId,
Date = DateTime.Parse(importModel.Date), Date = DateTime.Parse(importModel.Date),
Mileage = int.Parse(importModel.Odometer, NumberStyles.Any), Mileage = decimal.ToInt32(decimal.Parse(importModel.Odometer, NumberStyles.Any)),
Description = string.IsNullOrWhiteSpace(importModel.Description) ? $"Service Record on {importModel.Date}" : importModel.Description, Description = string.IsNullOrWhiteSpace(importModel.Description) ? $"Service Record on {importModel.Date}" : importModel.Description,
Notes = string.IsNullOrWhiteSpace(importModel.Notes) ? "" : importModel.Notes, Notes = string.IsNullOrWhiteSpace(importModel.Notes) ? "" : importModel.Notes,
Cost = decimal.Parse(importModel.Cost, NumberStyles.Any) Cost = decimal.Parse(importModel.Cost, NumberStyles.Any)
@@ -433,7 +433,7 @@ namespace CarCareTracker.Controllers
{ {
VehicleId = vehicleId, VehicleId = vehicleId,
Date = DateTime.Parse(importModel.Date), Date = DateTime.Parse(importModel.Date),
Mileage = int.Parse(importModel.Odometer, NumberStyles.Any), Mileage = decimal.ToInt32(decimal.Parse(importModel.Odometer, NumberStyles.Any)),
Notes = string.IsNullOrWhiteSpace(importModel.Notes) ? "" : importModel.Notes Notes = string.IsNullOrWhiteSpace(importModel.Notes) ? "" : importModel.Notes
}; };
_odometerRecordDataAccess.SaveOdometerRecordToVehicle(convertedRecord); _odometerRecordDataAccess.SaveOdometerRecordToVehicle(convertedRecord);
@@ -463,7 +463,7 @@ namespace CarCareTracker.Controllers
{ {
VehicleId = vehicleId, VehicleId = vehicleId,
Date = DateTime.Parse(importModel.Date), Date = DateTime.Parse(importModel.Date),
Mileage = int.Parse(importModel.Odometer, NumberStyles.Any), Mileage = decimal.ToInt32(decimal.Parse(importModel.Odometer, NumberStyles.Any)),
Description = string.IsNullOrWhiteSpace(importModel.Description) ? $"Repair Record on {importModel.Date}" : importModel.Description, Description = string.IsNullOrWhiteSpace(importModel.Description) ? $"Repair Record on {importModel.Date}" : importModel.Description,
Notes = string.IsNullOrWhiteSpace(importModel.Notes) ? "" : importModel.Notes, Notes = string.IsNullOrWhiteSpace(importModel.Notes) ? "" : importModel.Notes,
Cost = decimal.Parse(importModel.Cost, NumberStyles.Any) Cost = decimal.Parse(importModel.Cost, NumberStyles.Any)
@@ -476,7 +476,7 @@ namespace CarCareTracker.Controllers
{ {
VehicleId = vehicleId, VehicleId = vehicleId,
Date = DateTime.Parse(importModel.Date), Date = DateTime.Parse(importModel.Date),
Mileage = int.Parse(importModel.Odometer, NumberStyles.Any), Mileage = decimal.ToInt32(decimal.Parse(importModel.Odometer, NumberStyles.Any)),
Description = string.IsNullOrWhiteSpace(importModel.Description) ? $"Upgrade Record on {importModel.Date}" : importModel.Description, Description = string.IsNullOrWhiteSpace(importModel.Description) ? $"Upgrade Record on {importModel.Date}" : importModel.Description,
Notes = string.IsNullOrWhiteSpace(importModel.Notes) ? "" : importModel.Notes, Notes = string.IsNullOrWhiteSpace(importModel.Notes) ? "" : importModel.Notes,
Cost = decimal.Parse(importModel.Cost, NumberStyles.Any) Cost = decimal.Parse(importModel.Cost, NumberStyles.Any)

View File

@@ -71,7 +71,7 @@ function saveCollisionRecordToVehicle(isEdit) {
} }
function getAndValidateCollisionRecordValues() { function getAndValidateCollisionRecordValues() {
var collisionDate = $("#collisionRecordDate").val(); var collisionDate = $("#collisionRecordDate").val();
var collisionMileage = $("#collisionRecordMileage").val(); var collisionMileage = parseInt(globalParseFloat($("#collisionRecordMileage").val())).toString();
var collisionDescription = $("#collisionRecordDescription").val(); var collisionDescription = $("#collisionRecordDescription").val();
var collisionCost = $("#collisionRecordCost").val(); var collisionCost = $("#collisionRecordCost").val();
var collisionNotes = $("#collisionRecordNotes").val(); var collisionNotes = $("#collisionRecordNotes").val();

View File

@@ -68,7 +68,7 @@ function saveGasRecordToVehicle(isEdit) {
} }
function getAndValidateGasRecordValues() { function getAndValidateGasRecordValues() {
var gasDate = $("#gasRecordDate").val(); var gasDate = $("#gasRecordDate").val();
var gasMileage = $("#gasRecordMileage").val(); var gasMileage = parseInt(globalParseFloat($("#gasRecordMileage").val())).toString();
var gasGallons = $("#gasRecordGallons").val(); var gasGallons = $("#gasRecordGallons").val();
var gasCost = $("#gasRecordCost").val(); var gasCost = $("#gasRecordCost").val();
var gasCostType = $("#gasCostType").val(); var gasCostType = $("#gasCostType").val();

View File

@@ -71,7 +71,7 @@ function saveOdometerRecordToVehicle(isEdit) {
} }
function getAndValidateOdometerRecordValues() { function getAndValidateOdometerRecordValues() {
var serviceDate = $("#odometerRecordDate").val(); var serviceDate = $("#odometerRecordDate").val();
var serviceMileage = $("#odometerRecordMileage").val(); var serviceMileage = parseInt(globalParseFloat($("#odometerRecordMileage").val())).toString();
var serviceNotes = $("#odometerRecordNotes").val(); var serviceNotes = $("#odometerRecordNotes").val();
var vehicleId = GetVehicleId().vehicleId; var vehicleId = GetVehicleId().vehicleId;
var odometerRecordId = getOdometerRecordModelData().id; var odometerRecordId = getOdometerRecordModelData().id;

View File

@@ -96,7 +96,7 @@ function markDoneReminderRecord(reminderRecordId, e) {
function getAndValidateReminderRecordValues() { function getAndValidateReminderRecordValues() {
var reminderDate = $("#reminderDate").val(); var reminderDate = $("#reminderDate").val();
var reminderMileage = $("#reminderMileage").val(); var reminderMileage = parseInt(globalParseFloat($("#reminderMileage").val())).toString();
var reminderDescription = $("#reminderDescription").val(); var reminderDescription = $("#reminderDescription").val();
var reminderNotes = $("#reminderNotes").val(); var reminderNotes = $("#reminderNotes").val();
var reminderOption = $('#reminderOptions input:radio:checked').val(); var reminderOption = $('#reminderOptions input:radio:checked').val();

View File

@@ -71,7 +71,7 @@ function saveServiceRecordToVehicle(isEdit) {
} }
function getAndValidateServiceRecordValues() { function getAndValidateServiceRecordValues() {
var serviceDate = $("#serviceRecordDate").val(); var serviceDate = $("#serviceRecordDate").val();
var serviceMileage = $("#serviceRecordMileage").val(); var serviceMileage = parseInt(globalParseFloat($("#serviceRecordMileage").val())).toString();
var serviceDescription = $("#serviceRecordDescription").val(); var serviceDescription = $("#serviceRecordDescription").val();
var serviceCost = $("#serviceRecordCost").val(); var serviceCost = $("#serviceRecordCost").val();
var serviceNotes = $("#serviceRecordNotes").val(); var serviceNotes = $("#serviceRecordNotes").val();

View File

@@ -71,7 +71,7 @@ function saveUpgradeRecordToVehicle(isEdit) {
} }
function getAndValidateUpgradeRecordValues() { function getAndValidateUpgradeRecordValues() {
var upgradeDate = $("#upgradeRecordDate").val(); var upgradeDate = $("#upgradeRecordDate").val();
var upgradeMileage = $("#upgradeRecordMileage").val(); var upgradeMileage = parseInt(globalParseFloat($("#upgradeRecordMileage").val())).toString();
var upgradeDescription = $("#upgradeRecordDescription").val(); var upgradeDescription = $("#upgradeRecordDescription").val();
var upgradeCost = $("#upgradeRecordCost").val(); var upgradeCost = $("#upgradeRecordCost").val();
var upgradeNotes = $("#upgradeRecordNotes").val(); var upgradeNotes = $("#upgradeRecordNotes").val();