Merge pull request #402 from hargata/Hargata/further.improvements
More enhancements
This commit is contained in:
@@ -143,7 +143,7 @@ namespace CarCareTracker.Controllers
|
||||
};
|
||||
_odometerLogic.AutoInsertOdometerRecord(odometerRecord);
|
||||
}
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), vehicleId, User.Identity.Name, $"added service record via API {serviceRecord.Description}");
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), vehicleId, User.Identity.Name, $"Added Service Record via API - Description: {serviceRecord.Description}");
|
||||
response.Success = true;
|
||||
response.Message = "Service Record Added";
|
||||
return Json(response);
|
||||
@@ -211,7 +211,7 @@ namespace CarCareTracker.Controllers
|
||||
};
|
||||
_odometerLogic.AutoInsertOdometerRecord(odometerRecord);
|
||||
}
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), vehicleId, User.Identity.Name, $"added repair record via API {repairRecord.Description}");
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), vehicleId, User.Identity.Name, $"Added Repair Record via API - Description: {repairRecord.Description}");
|
||||
response.Success = true;
|
||||
response.Message = "Repair Record Added";
|
||||
return Json(response);
|
||||
@@ -279,7 +279,7 @@ namespace CarCareTracker.Controllers
|
||||
};
|
||||
_odometerLogic.AutoInsertOdometerRecord(odometerRecord);
|
||||
}
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), vehicleId, User.Identity.Name, $"added upgrade record via API {upgradeRecord.Description}");
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), vehicleId, User.Identity.Name, $"Added Upgrade Record via API - Description: {upgradeRecord.Description}");
|
||||
response.Success = true;
|
||||
response.Message = "Upgrade Record Added";
|
||||
return Json(response);
|
||||
@@ -333,7 +333,7 @@ namespace CarCareTracker.Controllers
|
||||
Cost = decimal.Parse(input.Cost)
|
||||
};
|
||||
_taxRecordDataAccess.SaveTaxRecordToVehicle(taxRecord);
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), vehicleId, User.Identity.Name, $"added tax record via API {taxRecord.Description}");
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), vehicleId, User.Identity.Name, $"Added Tax Record via API - Description: {taxRecord.Description}");
|
||||
response.Success = true;
|
||||
response.Message = "Tax Record Added";
|
||||
return Json(response);
|
||||
@@ -400,7 +400,7 @@ namespace CarCareTracker.Controllers
|
||||
Mileage = int.Parse(input.Odometer)
|
||||
};
|
||||
_odometerRecordDataAccess.SaveOdometerRecordToVehicle(odometerRecord);
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), vehicleId, User.Identity.Name, $"added odometer record via API {odometerRecord.Mileage.ToString()}");
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), vehicleId, User.Identity.Name, $"Added Odometer Record via API - Mileage: {odometerRecord.Mileage.ToString()}");
|
||||
response.Success = true;
|
||||
response.Message = "Odometer Record Added";
|
||||
return Json(response);
|
||||
@@ -482,7 +482,7 @@ namespace CarCareTracker.Controllers
|
||||
};
|
||||
_odometerLogic.AutoInsertOdometerRecord(odometerRecord);
|
||||
}
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), vehicleId, User.Identity.Name, $"added gas record via API {gasRecord.Mileage.ToString()}");
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), vehicleId, User.Identity.Name, $"Added Gas record via API - Mileage: {gasRecord.Mileage.ToString()}");
|
||||
response.Success = true;
|
||||
response.Message = "Gas Record Added";
|
||||
return Json(response);
|
||||
|
||||
@@ -130,10 +130,10 @@ namespace CarCareTracker.Controllers
|
||||
if (isNewAddition)
|
||||
{
|
||||
_userLogic.AddUserAccessToVehicle(GetUserID(), vehicleInput.Id);
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), vehicleInput.Id, User.Identity.Name, $"added new vehicle {vehicleInput.Year} {vehicleInput.Make} {vehicleInput.Model}");
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), vehicleInput.Id, User.Identity.Name, $"Added Vehicle - Description: {vehicleInput.Year} {vehicleInput.Make} {vehicleInput.Model}");
|
||||
} else
|
||||
{
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), vehicleInput.Id, User.Identity.Name, $"edited vehicle {vehicleInput.Year} {vehicleInput.Make} {vehicleInput.Model}");
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), vehicleInput.Id, User.Identity.Name, $"Edited Vehicle - Description: {vehicleInput.Year} {vehicleInput.Make} {vehicleInput.Model}");
|
||||
}
|
||||
return Json(result);
|
||||
}
|
||||
@@ -163,7 +163,7 @@ namespace CarCareTracker.Controllers
|
||||
_dataAccess.DeleteVehicle(vehicleId);
|
||||
if (result)
|
||||
{
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), vehicleId, User.Identity.Name, "deleted vehicle");
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), vehicleId, User.Identity.Name, "Deleted Vehicle");
|
||||
}
|
||||
return Json(result);
|
||||
}
|
||||
@@ -671,7 +671,7 @@ namespace CarCareTracker.Controllers
|
||||
var result = _gasRecordDataAccess.SaveGasRecordToVehicle(gasRecord.ToGasRecord());
|
||||
if (result)
|
||||
{
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), gasRecord.VehicleId, User.Identity.Name, $"saved gas record {gasRecord.Mileage.ToString()}");
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), gasRecord.VehicleId, User.Identity.Name, $"{(gasRecord.Id == default ? "Created" : "Edited")} Gas Record - Mileage: {gasRecord.Mileage.ToString()}");
|
||||
}
|
||||
return Json(result);
|
||||
}
|
||||
@@ -719,7 +719,7 @@ namespace CarCareTracker.Controllers
|
||||
var result = _gasRecordDataAccess.DeleteGasRecordById(gasRecordId);
|
||||
if (result)
|
||||
{
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), 0, User.Identity.Name, $"deleted gas record id {gasRecordId}");
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), 0, User.Identity.Name, $"Deleted Gas Record - Id: {gasRecordId}");
|
||||
}
|
||||
return Json(result);
|
||||
}
|
||||
@@ -777,7 +777,7 @@ namespace CarCareTracker.Controllers
|
||||
var result = _serviceRecordDataAccess.SaveServiceRecordToVehicle(serviceRecord.ToServiceRecord());
|
||||
if (result)
|
||||
{
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), serviceRecord.VehicleId, User.Identity.Name, $"saved service record {serviceRecord.Description}");
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), serviceRecord.VehicleId, User.Identity.Name, $"{(serviceRecord.Id == default ? "Created" : "Edited")} Service Record - Description: {serviceRecord.Description}");
|
||||
}
|
||||
return Json(result);
|
||||
}
|
||||
@@ -813,7 +813,7 @@ namespace CarCareTracker.Controllers
|
||||
var result = _serviceRecordDataAccess.DeleteServiceRecordById(serviceRecordId);
|
||||
if (result)
|
||||
{
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), 0, User.Identity.Name, $"deleted service record id {serviceRecordId}");
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), 0, User.Identity.Name, $"Deleted Service Record - Id: {serviceRecordId}");
|
||||
}
|
||||
return Json(result);
|
||||
}
|
||||
@@ -862,7 +862,7 @@ namespace CarCareTracker.Controllers
|
||||
var result = _collisionRecordDataAccess.SaveCollisionRecordToVehicle(collisionRecord.ToCollisionRecord());
|
||||
if (result)
|
||||
{
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), collisionRecord.VehicleId, User.Identity.Name, $"saved repair record {collisionRecord.Description}");
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), collisionRecord.VehicleId, User.Identity.Name, $"{(collisionRecord.Id == default ? "Created" : "Edited")} Repair Record - Description: {collisionRecord.Description}");
|
||||
}
|
||||
return Json(result);
|
||||
}
|
||||
@@ -898,7 +898,7 @@ namespace CarCareTracker.Controllers
|
||||
var result = _collisionRecordDataAccess.DeleteCollisionRecordById(collisionRecordId);
|
||||
if (result)
|
||||
{
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), 0, User.Identity.Name, $"deleted repair record id {collisionRecordId}");
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), 0, User.Identity.Name, $"Deleted Repair Record - Id: {collisionRecordId}");
|
||||
}
|
||||
return Json(result);
|
||||
}
|
||||
@@ -973,7 +973,7 @@ namespace CarCareTracker.Controllers
|
||||
var result = _taxRecordDataAccess.SaveTaxRecordToVehicle(taxRecord.ToTaxRecord());
|
||||
if (result)
|
||||
{
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), taxRecord.VehicleId, User.Identity.Name, $"saved tax record {taxRecord.Description}");
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), taxRecord.VehicleId, User.Identity.Name, $"{(taxRecord.Id == default ? "Created" : "Edited")} Tax Record - Description: {taxRecord.Description}");
|
||||
}
|
||||
return Json(result);
|
||||
}
|
||||
@@ -1010,7 +1010,7 @@ namespace CarCareTracker.Controllers
|
||||
var result = _taxRecordDataAccess.DeleteTaxRecordById(taxRecordId);
|
||||
if (result)
|
||||
{
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), 0, User.Identity.Name, $"deleted tax record {taxRecordId}");
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), 0, User.Identity.Name, $"Deleted Tax Record - Id: {taxRecordId}");
|
||||
}
|
||||
return Json(result);
|
||||
}
|
||||
@@ -1586,7 +1586,7 @@ namespace CarCareTracker.Controllers
|
||||
var result = _reminderRecordDataAccess.SaveReminderRecordToVehicle(reminderRecord.ToReminderRecord());
|
||||
if (result)
|
||||
{
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), reminderRecord.VehicleId, User.Identity.Name, $"saved reminder {reminderRecord.Description}");
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), reminderRecord.VehicleId, User.Identity.Name, $"{(reminderRecord.Id == default ? "Created" : "Edited")} Reminder - Description: {reminderRecord.Description}");
|
||||
}
|
||||
return Json(result);
|
||||
}
|
||||
@@ -1630,7 +1630,7 @@ namespace CarCareTracker.Controllers
|
||||
var result = _reminderRecordDataAccess.DeleteReminderRecordById(reminderRecordId);
|
||||
if (result)
|
||||
{
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), 0, User.Identity.Name, $"deleted reminder id {reminderRecordId}");
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), 0, User.Identity.Name, $"Deleted Reminder - Id: {reminderRecordId}");
|
||||
}
|
||||
return Json(result);
|
||||
}
|
||||
@@ -1679,7 +1679,7 @@ namespace CarCareTracker.Controllers
|
||||
var result = _upgradeRecordDataAccess.SaveUpgradeRecordToVehicle(upgradeRecord.ToUpgradeRecord());
|
||||
if (result)
|
||||
{
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), upgradeRecord.VehicleId, User.Identity.Name, $"saved upgrade record {upgradeRecord.Description}");
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), upgradeRecord.VehicleId, User.Identity.Name, $"{(upgradeRecord.Id == default ? "Created" : "Edited")} Upgrade Record - Description: {upgradeRecord.Description}");
|
||||
}
|
||||
return Json(result);
|
||||
}
|
||||
@@ -1715,7 +1715,7 @@ namespace CarCareTracker.Controllers
|
||||
var result = _upgradeRecordDataAccess.DeleteUpgradeRecordById(upgradeRecordId);
|
||||
if (result)
|
||||
{
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), 0, User.Identity.Name, $"deleted upgrade record id {upgradeRecordId}");
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), 0, User.Identity.Name, $"Deleted Upgrade Record - Id: {upgradeRecordId}");
|
||||
}
|
||||
return Json(result);
|
||||
}
|
||||
@@ -1743,7 +1743,7 @@ namespace CarCareTracker.Controllers
|
||||
var result = _noteDataAccess.SaveNoteToVehicle(note);
|
||||
if (result)
|
||||
{
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), note.VehicleId, User.Identity.Name, $"saved note {note.Description}");
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), note.VehicleId, User.Identity.Name, $"{(note.Id == default ? "Created" : "Edited")} Note - Description: {note.Description}");
|
||||
}
|
||||
return Json(result);
|
||||
}
|
||||
@@ -1764,7 +1764,7 @@ namespace CarCareTracker.Controllers
|
||||
var result = _noteDataAccess.DeleteNoteById(noteId);
|
||||
if (result)
|
||||
{
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), 0, User.Identity.Name, $"deleted note id {noteId}");
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), 0, User.Identity.Name, $"Deleted Note - Id: {noteId}");
|
||||
}
|
||||
return Json(result);
|
||||
}
|
||||
@@ -1889,7 +1889,7 @@ namespace CarCareTracker.Controllers
|
||||
var result = _supplyRecordDataAccess.SaveSupplyRecordToVehicle(supplyRecord.ToSupplyRecord());
|
||||
if (result)
|
||||
{
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), supplyRecord.VehicleId, User.Identity.Name, $"saved supply record {supplyRecord.Description}");
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), supplyRecord.VehicleId, User.Identity.Name, $"{(supplyRecord.Id == default ? "Created" : "Edited")} Supply Record - Description: {supplyRecord.Description}");
|
||||
}
|
||||
return Json(result);
|
||||
}
|
||||
@@ -1927,7 +1927,7 @@ namespace CarCareTracker.Controllers
|
||||
var result = _supplyRecordDataAccess.DeleteSupplyRecordById(supplyRecordId);
|
||||
if (result)
|
||||
{
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), 0, User.Identity.Name, $"deleted supply record id {supplyRecordId}");
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), 0, User.Identity.Name, $"Deleted Supply Record - Id: {supplyRecordId}");
|
||||
}
|
||||
return Json(result);
|
||||
}
|
||||
@@ -1958,7 +1958,7 @@ namespace CarCareTracker.Controllers
|
||||
var result = _planRecordDataAccess.SavePlanRecordToVehicle(planRecord.ToPlanRecord());
|
||||
if (result)
|
||||
{
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), planRecord.VehicleId, User.Identity.Name, $"saved plan record {planRecord.Description}");
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), planRecord.VehicleId, User.Identity.Name, $"{(planRecord.Id == default ? "Created" : "Edited")} Plan Record - Description: {planRecord.Description}");
|
||||
}
|
||||
return Json(result);
|
||||
}
|
||||
@@ -2147,7 +2147,7 @@ namespace CarCareTracker.Controllers
|
||||
var result = _planRecordDataAccess.DeletePlanRecordById(planRecordId);
|
||||
if (result)
|
||||
{
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), 0, User.Identity.Name, $"deleted plan record {planRecordId}");
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), 0, User.Identity.Name, $"Deleted Plan Record - Id: {planRecordId}");
|
||||
}
|
||||
return Json(result);
|
||||
}
|
||||
@@ -2190,7 +2190,7 @@ namespace CarCareTracker.Controllers
|
||||
var result = _odometerRecordDataAccess.SaveOdometerRecordToVehicle(odometerRecord.ToOdometerRecord());
|
||||
if (result)
|
||||
{
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), odometerRecord.VehicleId, User.Identity.Name, $"saved odometer record {odometerRecord.Mileage.ToString()}");
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), odometerRecord.VehicleId, User.Identity.Name, $"{(odometerRecord.Id == default ? "Created" : "Edited")} Odometer Record - Mileage: {odometerRecord.Mileage.ToString()}");
|
||||
}
|
||||
return Json(result);
|
||||
}
|
||||
@@ -2274,7 +2274,7 @@ namespace CarCareTracker.Controllers
|
||||
var result = _odometerRecordDataAccess.DeleteOdometerRecordById(odometerRecordId);
|
||||
if (result)
|
||||
{
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), 0, User.Identity.Name, $"deleted odometer record {odometerRecordId}");
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), 0, User.Identity.Name, $"Deleted Odometer Record - Id: {odometerRecordId}");
|
||||
}
|
||||
return Json(result);
|
||||
}
|
||||
@@ -2379,7 +2379,7 @@ namespace CarCareTracker.Controllers
|
||||
}
|
||||
if (result)
|
||||
{
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), 0, User.Identity.Name, $"moved multiple {source.ToString()} to {destination.ToString()} {string.Join(",", recordIds)}");
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), 0, User.Identity.Name, $"Moved multiple {source.ToString()} to {destination.ToString()} - Ids: {string.Join(",", recordIds)}");
|
||||
}
|
||||
return Json(result);
|
||||
}
|
||||
@@ -2421,7 +2421,66 @@ namespace CarCareTracker.Controllers
|
||||
}
|
||||
if (result)
|
||||
{
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), 0, User.Identity.Name, $"deleted multiple {importMode.ToString()} {string.Join(",", recordIds)}");
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), 0, User.Identity.Name, $"Deleted multiple {importMode.ToString()} - Ids: {string.Join(",", recordIds)}");
|
||||
}
|
||||
return Json(result);
|
||||
}
|
||||
[TypeFilter(typeof(CollaboratorFilter))]
|
||||
[HttpPost]
|
||||
public IActionResult AdjustRecordsOdometer(List<int> recordIds, int vehicleId, ImportMode importMode)
|
||||
{
|
||||
bool result = false;
|
||||
//get vehicle's odometer adjustments
|
||||
var vehicleData = _dataAccess.GetVehicleById(vehicleId);
|
||||
foreach (int recordId in recordIds)
|
||||
{
|
||||
switch (importMode)
|
||||
{
|
||||
case ImportMode.ServiceRecord:
|
||||
{
|
||||
var existingRecord = _serviceRecordDataAccess.GetServiceRecordById(recordId);
|
||||
existingRecord.Mileage += int.Parse(vehicleData.OdometerDifference);
|
||||
existingRecord.Mileage = decimal.ToInt32(existingRecord.Mileage * decimal.Parse(vehicleData.OdometerMultiplier, NumberStyles.Any));
|
||||
result = _serviceRecordDataAccess.SaveServiceRecordToVehicle(existingRecord);
|
||||
}
|
||||
break;
|
||||
case ImportMode.RepairRecord:
|
||||
{
|
||||
var existingRecord = _collisionRecordDataAccess.GetCollisionRecordById(recordId);
|
||||
existingRecord.Mileage += int.Parse(vehicleData.OdometerDifference);
|
||||
existingRecord.Mileage = decimal.ToInt32(existingRecord.Mileage * decimal.Parse(vehicleData.OdometerMultiplier, NumberStyles.Any));
|
||||
result = _collisionRecordDataAccess.SaveCollisionRecordToVehicle(existingRecord);
|
||||
}
|
||||
break;
|
||||
case ImportMode.UpgradeRecord:
|
||||
{
|
||||
var existingRecord = _upgradeRecordDataAccess.GetUpgradeRecordById(recordId);
|
||||
existingRecord.Mileage += int.Parse(vehicleData.OdometerDifference);
|
||||
existingRecord.Mileage = decimal.ToInt32(existingRecord.Mileage * decimal.Parse(vehicleData.OdometerMultiplier, NumberStyles.Any));
|
||||
result = _upgradeRecordDataAccess.SaveUpgradeRecordToVehicle(existingRecord);
|
||||
}
|
||||
break;
|
||||
case ImportMode.GasRecord:
|
||||
{
|
||||
var existingRecord = _gasRecordDataAccess.GetGasRecordById(recordId);
|
||||
existingRecord.Mileage += int.Parse(vehicleData.OdometerDifference);
|
||||
existingRecord.Mileage = decimal.ToInt32(existingRecord.Mileage * decimal.Parse(vehicleData.OdometerMultiplier, NumberStyles.Any));
|
||||
result = _gasRecordDataAccess.SaveGasRecordToVehicle(existingRecord);
|
||||
}
|
||||
break;
|
||||
case ImportMode.OdometerRecord:
|
||||
{
|
||||
var existingRecord = _odometerRecordDataAccess.GetOdometerRecordById(recordId);
|
||||
existingRecord.Mileage += int.Parse(vehicleData.OdometerDifference);
|
||||
existingRecord.Mileage = decimal.ToInt32(existingRecord.Mileage * decimal.Parse(vehicleData.OdometerMultiplier, NumberStyles.Any));
|
||||
result = _odometerRecordDataAccess.SaveOdometerRecordToVehicle(existingRecord);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (result)
|
||||
{
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), 0, User.Identity.Name, $"Adjusted odometer for multiple {importMode.ToString()} - Ids: {string.Join(",", recordIds)}");
|
||||
}
|
||||
return Json(result);
|
||||
}
|
||||
@@ -2499,7 +2558,7 @@ namespace CarCareTracker.Controllers
|
||||
}
|
||||
if (result)
|
||||
{
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), 0, User.Identity.Name, $"duplicated multiple {importMode.ToString()} {string.Join(",", recordIds)}");
|
||||
StaticHelper.NotifyAsync(_config.GetWebHookUrl(), 0, User.Identity.Name, $"Duplicated multiple {importMode.ToString()} - Ids: {string.Join(",", recordIds)}");
|
||||
}
|
||||
return Json(result);
|
||||
}
|
||||
|
||||
@@ -93,6 +93,7 @@ namespace CarCareTracker.Helper
|
||||
//copy over images and documents.
|
||||
var imagePath = Path.Combine(tempPath, "images");
|
||||
var documentPath = Path.Combine(tempPath, "documents");
|
||||
var translationPath = Path.Combine(tempPath, "translations");
|
||||
var dataPath = Path.Combine(tempPath, StaticHelper.DbName);
|
||||
var configPath = Path.Combine(tempPath, StaticHelper.UserConfigPath);
|
||||
if (Directory.Exists(imagePath))
|
||||
@@ -139,6 +140,28 @@ namespace CarCareTracker.Helper
|
||||
File.Copy(file, $"{existingPath}/{Path.GetFileName(file)}", true);
|
||||
}
|
||||
}
|
||||
if (Directory.Exists(translationPath))
|
||||
{
|
||||
var existingPath = Path.Combine(_webEnv.WebRootPath, "translations");
|
||||
if (!Directory.Exists(existingPath))
|
||||
{
|
||||
Directory.CreateDirectory(existingPath);
|
||||
}
|
||||
else if (clearExisting)
|
||||
{
|
||||
var filesToDelete = Directory.GetFiles(existingPath);
|
||||
foreach (string file in filesToDelete)
|
||||
{
|
||||
File.Delete(file);
|
||||
}
|
||||
}
|
||||
//copy each files from temp folder to newPath
|
||||
var filesToUpload = Directory.GetFiles(translationPath);
|
||||
foreach (string file in filesToUpload)
|
||||
{
|
||||
File.Copy(file, $"{existingPath}/{Path.GetFileName(file)}", true);
|
||||
}
|
||||
}
|
||||
if (File.Exists(dataPath))
|
||||
{
|
||||
//data path will always exist as it is created on startup if not.
|
||||
@@ -191,6 +214,7 @@ namespace CarCareTracker.Helper
|
||||
var tempPath = Path.Combine(_webEnv.WebRootPath, $"temp/{folderName}");
|
||||
var imagePath = Path.Combine(_webEnv.WebRootPath, "images");
|
||||
var documentPath = Path.Combine(_webEnv.WebRootPath, "documents");
|
||||
var translationPath = Path.Combine(_webEnv.WebRootPath, "translations");
|
||||
var dataPath = StaticHelper.DbName;
|
||||
var configPath = StaticHelper.UserConfigPath;
|
||||
if (!Directory.Exists(tempPath))
|
||||
@@ -215,6 +239,16 @@ namespace CarCareTracker.Helper
|
||||
File.Copy(file, $"{newPath}/{Path.GetFileName(file)}");
|
||||
}
|
||||
}
|
||||
if (Directory.Exists(translationPath))
|
||||
{
|
||||
var files = Directory.GetFiles(translationPath);
|
||||
foreach(var file in files)
|
||||
{
|
||||
var newPath = Path.Combine(tempPath, "translations");
|
||||
Directory.CreateDirectory(newPath);
|
||||
File.Copy(file, $"{newPath}/{Path.GetFileName(file)}");
|
||||
}
|
||||
}
|
||||
if (File.Exists(dataPath))
|
||||
{
|
||||
var newPath = Path.Combine(tempPath, "data");
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
ViewData["Title"] = "LubeLogger";
|
||||
}
|
||||
@section Scripts {
|
||||
<script src="~/js/garage.js"></script>
|
||||
<script src="~/js/supplyrecord.js"></script>
|
||||
<script src="~/js/garage.js?v=@StaticHelper.VersionNumber"></script>
|
||||
<script src="~/js/supplyrecord.js?v=@StaticHelper.VersionNumber"></script>
|
||||
<script src="~/lib/drawdown/drawdown.js"></script>
|
||||
}
|
||||
<div class="lubelogger-mobile-nav" onclick="hideMobileNav()">
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
ViewData["Title"] = "LubeLogger - Login";
|
||||
}
|
||||
@section Scripts {
|
||||
<script src="~/js/login.js"></script>
|
||||
<script src="~/js/login.js?v=@StaticHelper.VersionNumber"></script>
|
||||
}
|
||||
<div class="container d-flex align-items-center justify-content-center" style="height:100vh">
|
||||
<div class="row">
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
ViewData["Title"] = "LubeLogger - Login";
|
||||
}
|
||||
@section Scripts {
|
||||
<script src="~/js/login.js"></script>
|
||||
<script src="~/js/login.js?v=@StaticHelper.VersionNumber"></script>
|
||||
}
|
||||
<div class="container d-flex align-items-center justify-content-center" style="height:100vh">
|
||||
<div class="row">
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
ViewData["Title"] = "LubeLogger - Register";
|
||||
}
|
||||
@section Scripts {
|
||||
<script src="~/js/login.js"></script>
|
||||
<script src="~/js/login.js?v=@StaticHelper.VersionNumber"></script>
|
||||
}
|
||||
<div class="container d-flex align-items-center justify-content-center" style="height:100vh">
|
||||
<div class="row">
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
ViewData["Title"] = "LubeLogger - Register";
|
||||
}
|
||||
@section Scripts {
|
||||
<script src="~/js/login.js"></script>
|
||||
<script src="~/js/login.js?v=@StaticHelper.VersionNumber"></script>
|
||||
}
|
||||
<div class="container d-flex align-items-center justify-content-center" style="height:100vh">
|
||||
<div class="row">
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
ViewData["Title"] = "LubeLogger - Register";
|
||||
}
|
||||
@section Scripts {
|
||||
<script src="~/js/login.js"></script>
|
||||
<script src="~/js/login.js?v=@StaticHelper.VersionNumber"></script>
|
||||
}
|
||||
<div class="container d-flex align-items-center justify-content-center" style="height:100vh">
|
||||
<div class="row">
|
||||
|
||||
@@ -45,12 +45,12 @@
|
||||
<link rel="apple-touch-startup-image" href="~/defaults/lubelogger_launch.png" />
|
||||
<link rel="manifest" href="~/manifest.json">
|
||||
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||
<script src="~/js/shared.js"></script>
|
||||
<script src="~/js/shared.js?v=@StaticHelper.VersionNumber"></script>
|
||||
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="~/lib/bootstrap-datepicker/js/bootstrap-datepicker.min.js"></script>
|
||||
<script src="~/lib/bootstrap-tagsinput/bootstrap-tagsinput.js"></script>
|
||||
<script src="~/sweetalert/sweetalert2.all.min.js"></script>
|
||||
<script src="~/js/loader.js"></script>
|
||||
<script src="~/js/loader.js?v=@StaticHelper.VersionNumber"></script>
|
||||
<script>
|
||||
function getGlobalConfig() {
|
||||
return {
|
||||
|
||||
@@ -10,18 +10,18 @@
|
||||
}
|
||||
@model Vehicle
|
||||
@section Scripts {
|
||||
<script src="~/js/vehicle.js"></script>
|
||||
<script src="~/js/servicerecord.js"></script>
|
||||
<script src="~/js/gasrecord.js"></script>
|
||||
<script src="~/js/collisionrecord.js"></script>
|
||||
<script src="~/js/taxrecord.js"></script>
|
||||
<script src="~/js/reminderrecord.js"></script>
|
||||
<script src="~/js/upgraderecord.js"></script>
|
||||
<script src="~/js/note.js"></script>
|
||||
<script src="~/js/reports.js"></script>
|
||||
<script src="~/js/supplyrecord.js"></script>
|
||||
<script src="~/js/planrecord.js"></script>
|
||||
<script src="~/js/odometerrecord.js"></script>
|
||||
<script src="~/js/vehicle.js?v=@StaticHelper.VersionNumber"></script>
|
||||
<script src="~/js/servicerecord.js?v=@StaticHelper.VersionNumber"></script>
|
||||
<script src="~/js/gasrecord.js?v=@StaticHelper.VersionNumber"></script>
|
||||
<script src="~/js/collisionrecord.js?v=@StaticHelper.VersionNumber"></script>
|
||||
<script src="~/js/taxrecord.js?v=@StaticHelper.VersionNumber"></script>
|
||||
<script src="~/js/reminderrecord.js?v=@StaticHelper.VersionNumber"></script>
|
||||
<script src="~/js/upgraderecord.js?v=@StaticHelper.VersionNumber"></script>
|
||||
<script src="~/js/note.js?v=@StaticHelper.VersionNumber"></script>
|
||||
<script src="~/js/reports.js?v=@StaticHelper.VersionNumber"></script>
|
||||
<script src="~/js/supplyrecord.js?v=@StaticHelper.VersionNumber"></script>
|
||||
<script src="~/js/planrecord.js?v=@StaticHelper.VersionNumber"></script>
|
||||
<script src="~/js/odometerrecord.js?v=@StaticHelper.VersionNumber"></script>
|
||||
<script src="~/lib/chart-js/chart.umd.js"></script>
|
||||
<script src="~/lib/drawdown/drawdown.js"></script>
|
||||
}
|
||||
|
||||
@@ -159,6 +159,8 @@
|
||||
<li><a class="dropdown-item" href="#" onclick="deleteRecords(selectedRow, 'RepairRecord')">@translator.Translate(userLanguage, "Delete")</a></li>
|
||||
<li><hr class="context-menu-active-multiple dropdown-divider"></li>
|
||||
<li><a class="context-menu-active-multiple dropdown-item" href="#" onclick="getRecordsDeltaStats(selectedRow)">@translator.Translate(userLanguage, "Statistics")</a></li>
|
||||
<li><hr class="context-menu-odometer-adjustment dropdown-divider"></li>
|
||||
<li><a class="context-menu-odometer-adjustment dropdown-item" href="#" onclick="adjustRecordsOdometer(selectedRow, 'RepairRecord')">@translator.Translate(userLanguage, "Adjust Odometer")</a></li>
|
||||
</ul>
|
||||
@if (userColumnPreferences.Any())
|
||||
{
|
||||
|
||||
@@ -222,6 +222,8 @@
|
||||
<li><hr class="context-menu-multiple dropdown-divider"></li>
|
||||
<li><a class="dropdown-item" href="#" onclick="duplicateRecords(selectedRow, 'GasRecord')">@translator.Translate(userLanguage, "Duplicate")</a></li>
|
||||
<li><a class="dropdown-item" href="#" onclick="deleteRecords(selectedRow, 'GasRecord')">@translator.Translate(userLanguage, "Delete")</a></li>
|
||||
<li><hr class="context-menu-odometer-adjustment dropdown-divider"></li>
|
||||
<li><a class="context-menu-odometer-adjustment dropdown-item" href="#" onclick="adjustRecordsOdometer(selectedRow, 'GasRecord')">@translator.Translate(userLanguage, "Adjust Odometer")</a></li>
|
||||
</ul>
|
||||
@if (userColumnPreferences.Any())
|
||||
{
|
||||
|
||||
@@ -155,6 +155,8 @@
|
||||
<li><hr class="context-menu-multiple dropdown-divider"></li>
|
||||
<li><a class="dropdown-item" href="#" onclick="duplicateRecords(selectedRow, 'OdometerRecord')">@translator.Translate(userLanguage, "Duplicate")</a></li>
|
||||
<li><a class="dropdown-item" href="#" onclick="deleteRecords(selectedRow, 'OdometerRecord')">@translator.Translate(userLanguage, "Delete")</a></li>
|
||||
<li><hr class="context-menu-odometer-adjustment dropdown-divider"></li>
|
||||
<li><a class="context-menu-odometer-adjustment dropdown-item" href="#" onclick="adjustRecordsOdometer(selectedRow, 'OdometerRecord')">@translator.Translate(userLanguage, "Adjust Odometer")</a></li>
|
||||
</ul>
|
||||
@if (userColumnPreferences.Any())
|
||||
{
|
||||
|
||||
@@ -159,6 +159,8 @@
|
||||
<li><a class="dropdown-item" href="#" onclick="deleteRecords(selectedRow, 'ServiceRecord')">@translator.Translate(userLanguage, "Delete")</a></li>
|
||||
<li><hr class="context-menu-active-multiple dropdown-divider"></li>
|
||||
<li><a class="context-menu-active-multiple dropdown-item" href="#" onclick="getRecordsDeltaStats(selectedRow)">@translator.Translate(userLanguage, "Statistics")</a></li>
|
||||
<li><hr class="context-menu-odometer-adjustment dropdown-divider"></li>
|
||||
<li><a class="context-menu-odometer-adjustment dropdown-item" href="#" onclick="adjustRecordsOdometer(selectedRow, 'ServiceRecord')">@translator.Translate(userLanguage, "Adjust Odometer")</a></li>
|
||||
</ul>
|
||||
@if (userColumnPreferences.Any())
|
||||
{
|
||||
|
||||
@@ -158,6 +158,8 @@
|
||||
<li><a class="dropdown-item" href="#" onclick="deleteRecords(selectedRow, 'UpgradeRecord')">@translator.Translate(userLanguage, "Delete")</a></li>
|
||||
<li><hr class="context-menu-active-multiple dropdown-divider"></li>
|
||||
<li><a class="context-menu-active-multiple dropdown-item" href="#" onclick="getRecordsDeltaStats(selectedRow)">@translator.Translate(userLanguage, "Statistics")</a></li>
|
||||
<li><hr class="context-menu-odometer-adjustment dropdown-divider"></li>
|
||||
<li><a class="context-menu-odometer-adjustment dropdown-item" href="#" onclick="adjustRecordsOdometer(selectedRow, 'UpgradeRecord')">@translator.Translate(userLanguage, "Adjust Odometer")</a></li>
|
||||
</ul>
|
||||
@if (userColumnPreferences.Any())
|
||||
{
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -35,7 +35,7 @@ function getVehicleSupplyRecords() {
|
||||
});
|
||||
}
|
||||
function GetVehicleId() {
|
||||
return { vehicleId: 0 };
|
||||
return { vehicleId: 0, hasOdometerAdjustment: false };
|
||||
}
|
||||
function bindTabEvent() {
|
||||
$('button[data-bs-toggle="tab"]').on('show.bs.tab', function (e) {
|
||||
|
||||
@@ -814,6 +814,11 @@ function determineContextMenuItems() {
|
||||
} else {
|
||||
$(".context-menu-multiple").hide();
|
||||
}
|
||||
if (GetVehicleId().hasOdometerAdjustment) {
|
||||
$(".context-menu-odometer-adjustment").show();
|
||||
} else {
|
||||
$(".context-menu-odometer-adjustment").hide();
|
||||
}
|
||||
}
|
||||
function getMenuPosition(mouse, direction, scrollDir) {
|
||||
var win = $(window)[direction](),
|
||||
|
||||
@@ -476,7 +476,7 @@ function getRecordsDeltaStats(recordIds) {
|
||||
var divisibleCount = recordIds.length - 1;
|
||||
var averageOdo = diffOdo > 0 ? (diffOdo / divisibleCount).toFixed(2) : 0;
|
||||
var averageDays = diffDate > 0 ? Math.floor((diffDate / divisibleCount) / 8.64e7) : 0;
|
||||
var averageSum = costSum > 0 ? (costSum / divisibleCount).toFixed(2) : 0;
|
||||
var averageSum = costSum > 0 ? (costSum / recordIds.length).toFixed(2) : 0;
|
||||
costSum = costSum.toFixed(2);
|
||||
Swal.fire({
|
||||
title: "Record Statistics",
|
||||
@@ -501,4 +501,57 @@ function GetAdjustedOdometer(id, odometerInput) {
|
||||
//apply odometer multiplier.
|
||||
adjustedOdometer *= globalParseFloat(GetVehicleId().odometerMultiplier);
|
||||
return adjustedOdometer.toFixed(0);
|
||||
}
|
||||
function adjustRecordsOdometer(ids, source) {
|
||||
if (ids.length == 0) {
|
||||
return;
|
||||
}
|
||||
$("#workAroundInput").show();
|
||||
var friendlySource = "";
|
||||
var refreshDataCallBack;
|
||||
var recordVerbiage = ids.length > 1 ? `these ${ids.length} records` : "this record";
|
||||
switch (source) {
|
||||
case "ServiceRecord":
|
||||
friendlySource = "Service Records";
|
||||
refreshDataCallBack = getVehicleServiceRecords;
|
||||
break;
|
||||
case "RepairRecord":
|
||||
friendlySource = "Repairs";
|
||||
refreshDataCallBack = getVehicleCollisionRecords;
|
||||
break;
|
||||
case "UpgradeRecord":
|
||||
friendlySource = "Upgrades";
|
||||
refreshDataCallBack = getVehicleUpgradeRecords;
|
||||
break;
|
||||
case "OdometerRecord":
|
||||
friendlySource = "Odometer Records";
|
||||
refreshDataCallBack = getVehicleOdometerRecords;
|
||||
break;
|
||||
case "GasRecord":
|
||||
friendlySource = "Fuel Records";
|
||||
refreshDataCallBack = getVehicleGasRecords;
|
||||
break;
|
||||
}
|
||||
|
||||
Swal.fire({
|
||||
title: "Adjust Odometer?",
|
||||
text: `Apply Odometer Adjustments to ${recordVerbiage}?`,
|
||||
showCancelButton: true,
|
||||
confirmButtonText: "Adjust",
|
||||
confirmButtonColor: "#dc3545"
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
$.post('/Vehicle/AdjustRecordsOdometer', { recordIds: ids, vehicleId: GetVehicleId().vehicleId, importMode: source }, function (data) {
|
||||
if (data) {
|
||||
successToast(`${ids.length} Record(s) Updated`);
|
||||
var vehicleId = GetVehicleId().vehicleId;
|
||||
refreshDataCallBack(vehicleId);
|
||||
} else {
|
||||
errorToast(genericErrorMessage());
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$("#workAroundInput").hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user