-
-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from hargata/Hargata/consolidated.report
Hargata/consolidated.report
- Loading branch information
Showing
15 changed files
with
431 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
using CarCareTracker.Models; | ||
using System.Globalization; | ||
|
||
namespace CarCareTracker.Helper | ||
{ | ||
public interface IReportHelper | ||
{ | ||
IEnumerable<CostForVehicleByMonth> GetServiceRecordSum(List<ServiceRecord> serviceRecords, int year = 0); | ||
IEnumerable<CostForVehicleByMonth> GetRepairRecordSum(List<CollisionRecord> repairRecords, int year = 0); | ||
IEnumerable<CostForVehicleByMonth> GetUpgradeRecordSum(List<UpgradeRecord> upgradeRecords, int year = 0); | ||
IEnumerable<CostForVehicleByMonth> GetGasRecordSum(List<GasRecord> gasRecords, int year = 0); | ||
IEnumerable<CostForVehicleByMonth> GetTaxRecordSum(List<TaxRecord> taxRecords, int year = 0); | ||
} | ||
public class ReportHelper: IReportHelper | ||
{ | ||
public IEnumerable<CostForVehicleByMonth> GetServiceRecordSum(List<ServiceRecord> serviceRecords, int year = 0) | ||
{ | ||
if (year != default) | ||
{ | ||
serviceRecords.RemoveAll(x => x.Date.Year != year); | ||
} | ||
return serviceRecords.GroupBy(x => x.Date.Month).OrderBy(x => x.Key).Select(x => new CostForVehicleByMonth | ||
{ | ||
MonthName = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(x.Key), | ||
Cost = x.Sum(y => y.Cost) | ||
}); | ||
} | ||
public IEnumerable<CostForVehicleByMonth> GetRepairRecordSum(List<CollisionRecord> repairRecords, int year = 0) | ||
{ | ||
if (year != default) | ||
{ | ||
repairRecords.RemoveAll(x => x.Date.Year != year); | ||
} | ||
return repairRecords.GroupBy(x => x.Date.Month).OrderBy(x => x.Key).Select(x => new CostForVehicleByMonth | ||
{ | ||
MonthName = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(x.Key), | ||
Cost = x.Sum(y => y.Cost) | ||
}); | ||
} | ||
public IEnumerable<CostForVehicleByMonth> GetUpgradeRecordSum(List<UpgradeRecord> upgradeRecords, int year = 0) | ||
{ | ||
if (year != default) | ||
{ | ||
upgradeRecords.RemoveAll(x => x.Date.Year != year); | ||
} | ||
return upgradeRecords.GroupBy(x => x.Date.Month).OrderBy(x => x.Key).Select(x => new CostForVehicleByMonth | ||
{ | ||
MonthName = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(x.Key), | ||
Cost = x.Sum(y => y.Cost) | ||
}); | ||
} | ||
public IEnumerable<CostForVehicleByMonth> GetGasRecordSum(List<GasRecord> gasRecords, int year = 0) | ||
{ | ||
if (year != default) | ||
{ | ||
gasRecords.RemoveAll(x => x.Date.Year != year); | ||
} | ||
return gasRecords.GroupBy(x => x.Date.Month).OrderBy(x => x.Key).Select(x => new CostForVehicleByMonth | ||
{ | ||
MonthName = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(x.Key), | ||
Cost = x.Sum(y => y.Cost) | ||
}); | ||
} | ||
public IEnumerable<CostForVehicleByMonth> GetTaxRecordSum(List<TaxRecord> taxRecords, int year = 0) | ||
{ | ||
if (year != default) | ||
{ | ||
taxRecords.RemoveAll(x => x.Date.Year != year); | ||
} | ||
return taxRecords.GroupBy(x => x.Date.Month).OrderBy(x => x.Key).Select(x => new CostForVehicleByMonth | ||
{ | ||
MonthName = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(x.Key), | ||
Cost = x.Sum(y => y.Cost) | ||
}); | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
Models/Report/GasCostForVehicleByMonth.cs → Models/Report/CostForVehicleByMonth.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace CarCareTracker.Models | ||
{ | ||
public class ReminderMakeUpForVehicle | ||
{ | ||
public int NotUrgentCount { get; set; } | ||
public int UrgentCount { get; set; } | ||
public int VeryUrgentCount { get; set; } | ||
public int PastDueCount { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace CarCareTracker.Models | ||
{ | ||
public class ReportViewModel | ||
{ | ||
public List<CostForVehicleByMonth> CostForVehicleByMonth { get; set; } = new List<CostForVehicleByMonth>(); | ||
public CostMakeUpForVehicle CostMakeUpForVehicle { get; set; } = new CostMakeUpForVehicle(); | ||
public ReminderMakeUpForVehicle ReminderMakeUpForVehicle { get; set; } = new ReminderMakeUpForVehicle(); | ||
public List<int> Years { get; set; } = new List<int>(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.