diff --git a/Controllers/VehicleController.cs b/Controllers/VehicleController.cs index 2409534..2fcfff4 100644 --- a/Controllers/VehicleController.cs +++ b/Controllers/VehicleController.cs @@ -2,16 +2,9 @@ using CarCareTracker.External.Interfaces; using CarCareTracker.Models; using LiteDB; using Microsoft.AspNetCore.Mvc; -using System.Diagnostics; -using static System.Net.Mime.MediaTypeNames; -using System.Drawing; -using System.Linq.Expressions; -using Microsoft.Extensions.Logging; -using CarCareTracker.External.Implementations; using CarCareTracker.Helper; using CsvHelper; using System.Globalization; -using System.Runtime.InteropServices; namespace CarCareTracker.Controllers { @@ -415,10 +408,19 @@ namespace CarCareTracker.Controllers }; return PartialView("_CostMakeUpReport", viewModel); } - //public IActionResult GetFuelCostByMonthByVehicle(int vehicleId) - //{ - - //} + public IActionResult GetFuelCostByMonthByVehicle(int vehicleId, int year = 0) + { + var gasRecords = _gasRecordDataAccess.GetGasRecordsByVehicleId(vehicleId); + if (year != default) + { + gasRecords.RemoveAll(x => x.Date.Year != year); + } + var groupedGasRecord = gasRecords.GroupBy(x => x.Date.Month).OrderBy(x=>x.Key).Select(x => new GasCostForVehicleByMonth { + MonthName = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(x.Key), + Cost = x.Sum(y=>y.Cost) + }).ToList(); + return PartialView("_GasCostByMonthReport", groupedGasRecord); + } #endregion } } diff --git a/Models/Report/GasCostForVehicleByMonth.cs b/Models/Report/GasCostForVehicleByMonth.cs new file mode 100644 index 0000000..fd93ece --- /dev/null +++ b/Models/Report/GasCostForVehicleByMonth.cs @@ -0,0 +1,8 @@ +namespace CarCareTracker.Models +{ + public class GasCostForVehicleByMonth + { + public string MonthName { get; set; } + public decimal Cost { get; set; } + } +} diff --git a/Views/Vehicle/_CostMakeUpReport.cshtml b/Views/Vehicle/_CostMakeUpReport.cshtml index 5141e66..4bb252e 100644 --- a/Views/Vehicle/_CostMakeUpReport.cshtml +++ b/Views/Vehicle/_CostMakeUpReport.cshtml @@ -1,5 +1,5 @@ @model CostMakeUpForVehicle - + \ No newline at end of file diff --git a/Views/Vehicle/_Report.cshtml b/Views/Vehicle/_Report.cshtml index ab6e977..c42d979 100644 --- a/Views/Vehicle/_Report.cshtml +++ b/Views/Vehicle/_Report.cshtml @@ -6,8 +6,7 @@
-
- +
@@ -17,6 +16,10 @@ +
+
+
+
\ No newline at end of file diff --git a/appsettings.json b/appsettings.json index 528a826..a37c750 100644 --- a/appsettings.json +++ b/appsettings.json @@ -7,5 +7,5 @@ }, "AllowedHosts": "*", "DarkMode": true, - "EnableCsvImports": false + "EnableCsvImports": true } diff --git a/wwwroot/css/site.css b/wwwroot/css/site.css index fe70ebd..6b5866e 100644 --- a/wwwroot/css/site.css +++ b/wwwroot/css/site.css @@ -36,6 +36,11 @@ html { overflow-x:auto; } +.chartContainer{ + height:65vh; + overflow:auto; +} + .vehicleNoteContainer{ height:40vh; } \ No newline at end of file