@@ -24,6 +24,8 @@ public class APIController : Controller
2424 private readonly ISupplyRecordDataAccess _supplyRecordDataAccess ;
2525 private readonly IPlanRecordDataAccess _planRecordDataAccess ;
2626 private readonly IPlanRecordTemplateDataAccess _planRecordTemplateDataAccess ;
27+ private readonly IInspectionRecordDataAccess _inspectionRecordDataAccess ;
28+ private readonly IInspectionRecordTemplateDataAccess _inspectionRecordTemplateDataAccess ;
2729 private readonly IUserAccessDataAccess _userAccessDataAccess ;
2830 private readonly IUserRecordDataAccess _userRecordDataAccess ;
2931 private readonly IReminderHelper _reminderHelper ;
@@ -49,6 +51,8 @@ public APIController(IVehicleDataAccess dataAccess,
4951 ISupplyRecordDataAccess supplyRecordDataAccess ,
5052 IPlanRecordDataAccess planRecordDataAccess ,
5153 IPlanRecordTemplateDataAccess planRecordTemplateDataAccess ,
54+ IInspectionRecordDataAccess inspectionRecordDataAccess ,
55+ IInspectionRecordTemplateDataAccess inspectionRecordTemplateDataAccess ,
5256 IUserAccessDataAccess userAccessDataAccess ,
5357 IUserRecordDataAccess userRecordDataAccess ,
5458 IMailHelper mailHelper ,
@@ -71,6 +75,8 @@ public APIController(IVehicleDataAccess dataAccess,
7175 _supplyRecordDataAccess = supplyRecordDataAccess ;
7276 _planRecordDataAccess = planRecordDataAccess ;
7377 _planRecordTemplateDataAccess = planRecordTemplateDataAccess ;
78+ _inspectionRecordDataAccess = inspectionRecordDataAccess ;
79+ _inspectionRecordTemplateDataAccess = inspectionRecordTemplateDataAccess ;
7480 _userAccessDataAccess = userAccessDataAccess ;
7581 _userRecordDataAccess = userRecordDataAccess ;
7682 _mailHelper = mailHelper ;
@@ -533,7 +539,8 @@ public IActionResult AddServiceRecord(int vehicleId, GenericRecordExportModel in
533539 VehicleId = vehicleId ,
534540 Date = DateTime . Parse ( input . Date ) ,
535541 Notes = string . IsNullOrWhiteSpace ( input . Notes ) ? "" : input . Notes ,
536- Mileage = int . Parse ( input . Odometer )
542+ Mileage = int . Parse ( input . Odometer ) ,
543+ Files = StaticHelper . CreateAttachmentFromRecord ( ImportMode . ServiceRecord , serviceRecord . Id , serviceRecord . Description )
537544 } ;
538545 _odometerLogic . AutoInsertOdometerRecord ( odometerRecord ) ;
539546 }
@@ -728,7 +735,8 @@ public IActionResult AddRepairRecord(int vehicleId, GenericRecordExportModel inp
728735 VehicleId = vehicleId ,
729736 Date = DateTime . Parse ( input . Date ) ,
730737 Notes = string . IsNullOrWhiteSpace ( input . Notes ) ? "" : input . Notes ,
731- Mileage = int . Parse ( input . Odometer )
738+ Mileage = int . Parse ( input . Odometer ) ,
739+ Files = StaticHelper . CreateAttachmentFromRecord ( ImportMode . RepairRecord , repairRecord . Id , repairRecord . Description )
732740 } ;
733741 _odometerLogic . AutoInsertOdometerRecord ( odometerRecord ) ;
734742 }
@@ -925,7 +933,8 @@ public IActionResult AddUpgradeRecord(int vehicleId, GenericRecordExportModel in
925933 VehicleId = vehicleId ,
926934 Date = DateTime . Parse ( input . Date ) ,
927935 Notes = string . IsNullOrWhiteSpace ( input . Notes ) ? "" : input . Notes ,
928- Mileage = int . Parse ( input . Odometer )
936+ Mileage = int . Parse ( input . Odometer ) ,
937+ Files = StaticHelper . CreateAttachmentFromRecord ( ImportMode . UpgradeRecord , upgradeRecord . Id , upgradeRecord . Description )
929938 } ;
930939 _odometerLogic . AutoInsertOdometerRecord ( odometerRecord ) ;
931940 }
@@ -1546,7 +1555,8 @@ public IActionResult AddGasRecord(int vehicleId, GasRecordExportModel input)
15461555 VehicleId = vehicleId ,
15471556 Date = DateTime . Parse ( input . Date ) ,
15481557 Notes = string . IsNullOrWhiteSpace ( input . Notes ) ? "" : input . Notes ,
1549- Mileage = int . Parse ( input . Odometer )
1558+ Mileage = int . Parse ( input . Odometer ) ,
1559+ Files = StaticHelper . CreateAttachmentFromRecord ( ImportMode . GasRecord , gasRecord . Id , $ "Gas Record - { gasRecord . Mileage . ToString ( ) } ")
15501560 } ;
15511561 _odometerLogic . AutoInsertOdometerRecord ( odometerRecord ) ;
15521562 }
@@ -1652,7 +1662,7 @@ public IActionResult UpdateGasRecord(GasRecordExportModel input)
16521662 [ TypeFilter ( typeof ( CollaboratorFilter ) ) ]
16531663 [ HttpGet ]
16541664 [ Route ( "/api/vehicle/reminders" ) ]
1655- public IActionResult Reminders ( int vehicleId , List < ReminderUrgency > urgencies )
1665+ public IActionResult Reminders ( int vehicleId , List < ReminderUrgency > urgencies , string tags )
16561666 {
16571667 if ( vehicleId == default )
16581668 {
@@ -1668,6 +1678,11 @@ public IActionResult Reminders(int vehicleId, List<ReminderUrgency> urgencies)
16681678 var reminders = _reminderRecordDataAccess . GetReminderRecordsByVehicleId ( vehicleId ) ;
16691679 var reminderResults = _reminderHelper . GetReminderRecordViewModels ( reminders , currentMileage , DateTime . Now ) ;
16701680 reminderResults . RemoveAll ( x => ! urgencies . Contains ( x . Urgency ) ) ;
1681+ if ( ! string . IsNullOrWhiteSpace ( tags ) )
1682+ {
1683+ var tagsFilter = tags . Split ( ' ' ) . Distinct ( ) ;
1684+ reminderResults . RemoveAll ( x => ! x . Tags . Any ( y => tagsFilter . Contains ( y ) ) ) ;
1685+ }
16711686 var results = reminderResults . Select ( x=> new ReminderAPIExportModel { Id = x . Id . ToString ( ) , Description = x . Description , Urgency = x . Urgency . ToString ( ) , Metric = x . Metric . ToString ( ) , UserMetric = x . UserMetric . ToString ( ) , Notes = x . Notes , DueDate = x . Date . ToShortDateString ( ) , DueOdometer = x . Mileage . ToString ( ) , DueDays = x . DueDays . ToString ( ) , DueDistance = x . DueMileage . ToString ( ) , Tags = string . Join ( ' ' , x . Tags ) } ) ;
16721687 if ( _config . GetInvariantApi ( ) || Request . Headers . ContainsKey ( "culture-invariant" ) )
16731688 {
@@ -1904,7 +1919,7 @@ public IActionResult UploadDocument(List<IFormFile> documents)
19041919 [ Authorize ( Roles = nameof ( UserData . IsRootUser ) ) ]
19051920 [ HttpGet ]
19061921 [ Route ( "/api/vehicle/reminders/send" ) ]
1907- public IActionResult SendReminders ( List < ReminderUrgency > urgencies )
1922+ public IActionResult SendReminders ( List < ReminderUrgency > urgencies , string tags )
19081923 {
19091924 if ( ! urgencies . Any ( ) )
19101925 {
@@ -1914,6 +1929,7 @@ public IActionResult SendReminders(List<ReminderUrgency> urgencies)
19141929 var vehicles = _dataAccess . GetVehicles ( ) ;
19151930 List < OperationResponse > operationResponses = new List < OperationResponse > ( ) ;
19161931 var defaultEmailAddress = _config . GetDefaultReminderEmail ( ) ;
1932+ List < string > tagsFilter = ! string . IsNullOrWhiteSpace ( tags ) ? tags . Split ( ' ' ) . Distinct ( ) . ToList ( ) : new List < string > ( ) ;
19171933 foreach ( Vehicle vehicle in vehicles )
19181934 {
19191935 var vehicleId = vehicle . Id ;
@@ -1922,6 +1938,10 @@ public IActionResult SendReminders(List<ReminderUrgency> urgencies)
19221938 var reminders = _reminderRecordDataAccess . GetReminderRecordsByVehicleId ( vehicleId ) ;
19231939 var results = _reminderHelper . GetReminderRecordViewModels ( reminders , currentMileage , DateTime . Now ) . OrderByDescending ( x => x . Urgency ) . ToList ( ) ;
19241940 results . RemoveAll ( x => ! urgencies . Contains ( x . Urgency ) ) ;
1941+ if ( tagsFilter . Any ( ) )
1942+ {
1943+ results . RemoveAll ( x => ! x . Tags . Any ( y => tagsFilter . Contains ( y ) ) ) ;
1944+ }
19251945 if ( ! results . Any ( ) )
19261946 {
19271947 continue ;
@@ -2004,6 +2024,8 @@ public IActionResult CleanUp(bool deepClean = false)
20042024 vehicleDocuments . AddRange ( _supplyRecordDataAccess . GetSupplyRecordsByVehicleId ( vehicle . Id ) . SelectMany ( x => x . Files ) . Select ( y => Path . GetFileName ( y . Location ) ) ) ;
20052025 vehicleDocuments . AddRange ( _planRecordDataAccess . GetPlanRecordsByVehicleId ( vehicle . Id ) . SelectMany ( x => x . Files ) . Select ( y => Path . GetFileName ( y . Location ) ) ) ;
20062026 vehicleDocuments . AddRange ( _planRecordTemplateDataAccess . GetPlanRecordTemplatesByVehicleId ( vehicle . Id ) . SelectMany ( x => x . Files ) . Select ( y => Path . GetFileName ( y . Location ) ) ) ;
2027+ vehicleDocuments . AddRange ( _inspectionRecordDataAccess . GetInspectionRecordsByVehicleId ( vehicle . Id ) . SelectMany ( x => x . Files ) . Select ( y => Path . GetFileName ( y . Location ) ) ) ;
2028+ vehicleDocuments . AddRange ( _inspectionRecordTemplateDataAccess . GetInspectionRecordTemplatesByVehicleId ( vehicle . Id ) . SelectMany ( x => x . Files ) . Select ( y => Path . GetFileName ( y . Location ) ) ) ;
20072029 }
20082030 //shop supplies
20092031 vehicleDocuments . AddRange ( _supplyRecordDataAccess . GetSupplyRecordsByVehicleId ( 0 ) . SelectMany ( x => x . Files ) . Select ( y => Path . GetFileName ( y . Location ) ) ) ;
0 commit comments