public static Inspection GetLastInspection(SQLiteConnection conn, int vehicleId) { var inspections = InspectionDbMapper.SelectAllByVehicleId(conn, vehicleId); List <Inspection> sortedInspections = inspections.OrderByDescending(c => c.InspectionDate).ToList(); if (sortedInspections.Count == 0) { return(null); } return(sortedInspections[0]); }
public static void Delete(SQLiteConnection conn, int id) { List <Notification> notifications = NotificationDbMapper.SelectByInspectionId(conn, id); foreach (Notification notify in notifications) { NotificationDbMapper.Delete(conn, notify.Id); } InspectionDbMapper.Delete(conn, id); }
public static int EndingInspectionsCount(SQLiteConnection conn, int adminId, int remainDays) { // vypíše všechny prohlídky u vozidel daného správce, které končí u určené lhůtě List <Inspection> inspections = InspectionDbMapper.SelectAllByVehicleAdminId(conn, 1); int inspectionsCount = 0; foreach (Inspection inspection in inspections) { int days = (inspection.ValidTo - DateTime.Now).Days; if (days <= remainDays) { inspectionsCount++; } } return(inspectionsCount); }
public static bool Delete(SQLiteConnection conn, int adminId, int vehicleId) { // má uživatel oprávnění? UserAdmin ua = UserAdminDbMapper.SelectById(conn, adminId); if (ua == null) { return(false); } // smazání všech prohlídek List <Inspection> inspections = InspectionDbMapper.SelectAllByVehicleId(conn, vehicleId); foreach (Inspection inspection in inspections) { InspectionLogic.Delete(conn, inspection.Id); } var delete = VehicleDbMapper.Delete(conn, vehicleId); return(delete == 0); }
public static bool Insert(SQLiteConnection conn, Inspection i, out string error) { if (i.InspectionDate >= i.ValidTo) { error = "Chybně vyplněné datum platnosti STK."; return(false); } if (i.Price < 0) { error = "Chybně vyplněná cena STK."; return(false); } int result = InspectionDbMapper.Insert(conn, i); if (result != 0) { error = "Prohlídku se nepodařilo uložit do DB."; } error = ""; return(true); }
public static List <Inspection> FindAllByVehicleId(SQLiteConnection conn, int vehicleId) { return(InspectionDbMapper.SelectAllByVehicleId(conn, vehicleId)); }
public static List <Inspection> FindAll(SQLiteConnection conn) { return(InspectionDbMapper.SelectAll(conn)); }