From 39b59d5660799944fe70cc06b756b97e9046d30c Mon Sep 17 00:00:00 2001 From: Mary Tran Date: Sun, 11 Nov 2018 23:25:07 -0500 Subject: [PATCH] Fixed HomeOwner to ServiceProvider --- .../olympus/olympusservices/DBHelper.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/DBHelper.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/DBHelper.java index 664dee9..05b794d 100644 --- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/DBHelper.java +++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/DBHelper.java @@ -238,7 +238,7 @@ public class DBHelper extends SQLiteOpenHelper { values.put(COLUMN_FIRSTNAME, userType.getFirstname()); values.put(COLUMN_LASTNAME, userType.getLastname()); values.put(COLUMN_USERTYPE, userType.getClass().getSimpleName()); - if (userType.getClass().getSimpleName().equals("Homeowner")){ + if (userType instanceof ServiceProvider){ ServiceProvider serviceProvider = (ServiceProvider)userType; String address = serviceProvider.getAddress(); @@ -678,6 +678,23 @@ public class DBHelper extends SQLiteOpenHelper { return serviceProvider.getAvailabilities(); } + public int[][] getAvailabilities(String serviceProviderName){ + int[][] availabilities = new int[7][4]; + if (serviceProviderName==null) return availabilities; + + Cursor cursor = readDB.rawQuery("SELECT * FROM " + TABLE_AVAILABILITY + + " WHERE " + COLUMN_AVAILABILITYNAME + " = ?", + new String[]{serviceProviderName}); + if (cursor.moveToFirst()){ + for (int i = 0; i < 7; i++) { + int start = cursor.getInt(i*2+1); + int end = cursor.getInt(i*2+2); + availabilities[i] = new int[]{start/60, start%60, end/60, end%60}; + } + } + return availabilities; + } + /** * Prints all entries of table. One row is printed per line. Columns are * separated by spaces.