diff --git a/Controllers/APIController.cs b/Controllers/APIController.cs index c41c67f..5ca76c0 100644 --- a/Controllers/APIController.cs +++ b/Controllers/APIController.cs @@ -118,7 +118,8 @@ namespace CarCareTracker.Controllers FuelConsumed = x.Gallons.ToString(), FuelEconomy = x.MilesPerGallon.ToString(), IsFillToFull = x.IsFillToFull.ToString(), - MissedFuelUp = x.MissedFuelUp.ToString() + MissedFuelUp = x.MissedFuelUp.ToString(), + Notes = x.Notes }); return Json(result); } diff --git a/Controllers/VehicleController.cs b/Controllers/VehicleController.cs index 403d9a8..5f4c24c 100644 --- a/Controllers/VehicleController.cs +++ b/Controllers/VehicleController.cs @@ -271,7 +271,8 @@ namespace CarCareTracker.Controllers FuelEconomy = x.MilesPerGallon.ToString(), Odometer = x.Mileage.ToString(), IsFillToFull = x.IsFillToFull.ToString(), - MissedFuelUp = x.MissedFuelUp.ToString() + MissedFuelUp = x.MissedFuelUp.ToString(), + Notes = x.Notes }); using (var writer = new StreamWriter(fullExportFilePath)) { @@ -321,7 +322,8 @@ namespace CarCareTracker.Controllers VehicleId = vehicleId, Date = DateTime.Parse(importModel.Date), Mileage = int.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 }; if (string.IsNullOrWhiteSpace(importModel.Cost) && !string.IsNullOrWhiteSpace(importModel.Price)) { @@ -487,7 +489,8 @@ namespace CarCareTracker.Controllers Files = result.Files, Gallons = result.Gallons, IsFillToFull = result.IsFillToFull, - MissedFuelUp = result.MissedFuelUp + MissedFuelUp = result.MissedFuelUp, + Notes = result.Notes }; var vehicleIsElectric = _dataAccess.GetVehicleById(convertedResult.VehicleId).IsElectric; var viewModel = new GasRecordInputContainer() diff --git a/Helper/GasHelper.cs b/Helper/GasHelper.cs index 752d4eb..a9c2a1a 100644 --- a/Helper/GasHelper.cs +++ b/Helper/GasHelper.cs @@ -44,7 +44,8 @@ namespace CarCareTracker.Helper DeltaMileage = deltaMileage, CostPerGallon = convertedConsumption > 0.00M ? currentObject.Cost / convertedConsumption : 0, IsFillToFull = currentObject.IsFillToFull, - MissedFuelUp = currentObject.MissedFuelUp + MissedFuelUp = currentObject.MissedFuelUp, + Notes = currentObject.Notes }; if (currentObject.MissedFuelUp) { @@ -88,7 +89,8 @@ namespace CarCareTracker.Helper MilesPerGallon = 0, CostPerGallon = convertedConsumption > 0.00M ? currentObject.Cost / convertedConsumption : 0, IsFillToFull = currentObject.IsFillToFull, - MissedFuelUp = currentObject.MissedFuelUp + MissedFuelUp = currentObject.MissedFuelUp, + Notes = currentObject.Notes }); } previousMileage = currentObject.Mileage; diff --git a/Models/GasRecord/GasRecord.cs b/Models/GasRecord/GasRecord.cs index 8739adc..336c60e 100644 --- a/Models/GasRecord/GasRecord.cs +++ b/Models/GasRecord/GasRecord.cs @@ -16,6 +16,7 @@ public decimal Cost { get; set; } public bool IsFillToFull { get; set; } = true; public bool MissedFuelUp { get; set; } = false; + public string Notes { get; set; } public List Files { get; set; } = new List(); } } diff --git a/Models/GasRecord/GasRecordInput.cs b/Models/GasRecord/GasRecordInput.cs index 2a5243c..37fe265 100644 --- a/Models/GasRecord/GasRecordInput.cs +++ b/Models/GasRecord/GasRecordInput.cs @@ -16,6 +16,7 @@ public decimal Cost { get; set; } public bool IsFillToFull { get; set; } = true; public bool MissedFuelUp { get; set; } = false; + public string Notes { get; set; } public List Files { get; set; } = new List(); public GasRecord ToGasRecord() { return new GasRecord { Id = Id, @@ -26,7 +27,8 @@ VehicleId = VehicleId, Files = Files, IsFillToFull = IsFillToFull, - MissedFuelUp = MissedFuelUp + MissedFuelUp = MissedFuelUp, + Notes = Notes }; } } } diff --git a/Models/GasRecord/GasRecordViewModel.cs b/Models/GasRecord/GasRecordViewModel.cs index 8979c8d..1eee41f 100644 --- a/Models/GasRecord/GasRecordViewModel.cs +++ b/Models/GasRecord/GasRecordViewModel.cs @@ -20,5 +20,6 @@ public decimal CostPerGallon { get; set; } public bool IsFillToFull { get; set; } public bool MissedFuelUp { get; set; } + public string Notes { get; set; } } } diff --git a/Models/ImportModel.cs b/Models/ImportModel.cs index a01256f..87270d8 100644 --- a/Models/ImportModel.cs +++ b/Models/ImportModel.cs @@ -56,6 +56,7 @@ public string FuelEconomy { get; set; } public string IsFillToFull { get; set; } public string MissedFuelUp { get; set; } + public string Notes { get; set; } } public class ReminderExportModel { diff --git a/Views/Vehicle/_GasModal.cshtml b/Views/Vehicle/_GasModal.cshtml index fc86707..6238ad6 100644 --- a/Views/Vehicle/_GasModal.cshtml +++ b/Views/Vehicle/_GasModal.cshtml @@ -56,9 +56,25 @@ - + @if (isNew) + { +
+ +
+ +
+
+ } else + { + + }
+ + @if (Model.GasRecord.Files.Any()) {
diff --git a/wwwroot/defaults/gassample.csv b/wwwroot/defaults/gassample.csv index 9dfd46b..323f792 100644 --- a/wwwroot/defaults/gassample.csv +++ b/wwwroot/defaults/gassample.csv @@ -1,3 +1,3 @@ -Date,Odometer,FuelConsumed,Cost,IsFillToFull,MissedFuelUp -5/8/2020,204836,8.331,16.24,True,False -5/30/2020,205056,11.913,25.72,True,False \ No newline at end of file +Date,Odometer,FuelConsumed,Cost,IsFillToFull,MissedFuelUp,Notes +5/8/2020,204836,8.331,16.24,True,False, +5/30/2020,205056,11.913,25.72,True,False, \ No newline at end of file diff --git a/wwwroot/js/gasrecord.js b/wwwroot/js/gasrecord.js index 414b324..9524575 100644 --- a/wwwroot/js/gasrecord.js +++ b/wwwroot/js/gasrecord.js @@ -71,8 +71,10 @@ function getAndValidateGasRecordValues() { var gasMileage = $("#gasRecordMileage").val(); var gasGallons = $("#gasRecordGallons").val(); var gasCost = $("#gasRecordCost").val(); + var gasCostType = $("#gasCostType").val(); var gasIsFillToFull = $("#gasIsFillToFull").is(":checked"); var gasIsMissed = $("#gasIsMissed").is(":checked"); + var gasNotes = $("#gasRecordNotes").val(); var vehicleId = GetVehicleId().vehicleId; var gasRecordId = getGasRecordModelData().id; //validation @@ -95,6 +97,17 @@ function getAndValidateGasRecordValues() { } else { $("#gasRecordGallons").removeClass("is-invalid"); } + if (gasCostType != undefined && gasCostType == 'unit') { + var convertedGasCost = parseFloat(gasCost) * parseFloat(gasGallons); + gasCost = convertedGasCost.toFixed(2).toString(); + if (isNaN(gasCost)) + { + hasError = true; + $("#gasRecordCost").addClass("is-invalid"); + } else { + $("#gasRecordCost").removeClass("is-invalid"); + } + } if (gasCost.trim() == '' || !isValidMoney(gasCost)) { hasError = true; $("#gasRecordCost").addClass("is-invalid"); @@ -111,6 +124,7 @@ function getAndValidateGasRecordValues() { cost: gasCost, files: uploadedFiles, isFillToFull: gasIsFillToFull, - missedFuelUp: gasIsMissed + missedFuelUp: gasIsMissed, + notes: gasNotes } } \ No newline at end of file