Skip to content
Snippets Groups Projects
Commit a2960b1c authored by Fabio Heyming's avatar Fabio Heyming
Browse files

Added favouriten to persistance

parent cbc291ee
Branches
No related tags found
1 merge request!1Mal aufn Master megren
...@@ -281,6 +281,18 @@ public class MampfMobil { ...@@ -281,6 +281,18 @@ public class MampfMobil {
CSVFileHelper.saveCSVFile(context, fileName6, csvBestellungen); CSVFileHelper.saveCSVFile(context, fileName6, csvBestellungen);
// bestellungsteil besteht aus Customer-ID, ShopItem-ID
String csvFavoriten = "";
for(Customer c:MampfMobil.customers){
for(ShopItem sI: c.favoriten){
csvFavoriten = csvFavoriten + c.id + ","+ sI.id + "\n";
}
}
String fileName7 = "favoriten.csv";
CSVFileHelper.saveCSVFile(context, fileName7, csvBestellungen);
} }
public static void takefromPersistance() { public static void takefromPersistance() {
...@@ -458,5 +470,33 @@ public class MampfMobil { ...@@ -458,5 +470,33 @@ public class MampfMobil {
} }
} }
} }
String fileName7 = "favoriten.csv";
String csvData7 = CSVFileHelper.loadCSVFile(context, fileName7);
if (csvData7 != null) {
String[] lines = csvData7.split("\n");
for (String line : lines) {
String[] data = line.split(",");
if (data.length >= 2) {
int cusId = Integer.parseInt(data[0]);
int shopItemId = Integer.parseInt(data[0]);
for (Customer c : MampfMobil.customers) {
if (c.id == cusId) {
for (Supplier s : MampfMobil.suppliers) {
for (ShopItem sI : s.shopItems) {
if (sI.id == shopItemId) {
c.addToFavourits(sI);
}
}
}
}
}
}
}
}
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment