public static int Create(SQLiteConnection conn, Vehicle vh, int typeId, int brandId, int driverId, int bossId) { // kontrola existence VIN v databázi bool vinExists = VehicleDbMapper.VinExists(conn, vh.Vin); if (vinExists) { return(-1); } vh.VehicleType = VehicleTypeXmlMapper.SelectById(typeId); vh.VehicleBrand = VehicleBrandXmlMapper.SelectById(brandId); vh.Driver = UserDriverDbMapper.SelectById(conn, 4); vh.Boss = UserBossDbMapper.SelectById(conn, 1); int result = VehicleDbMapper.Insert(conn, vh); return(result); }
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 long CountDriversByAdminId(SQLiteConnection conn, int adminId) { return(VehicleDbMapper.SelectDriversCountByAdminId(conn, adminId)); }
public static Vehicle FindById(SQLiteConnection conn, int id) { return(VehicleDbMapper.SelectById(conn, id)); }
public static List <Vehicle> FindAll(SQLiteConnection conn) { return(VehicleDbMapper.SelectAll(conn)); }