async void populateList() { DatabaseGET conn = new DatabaseGET(); List <ConnectHelpers.NotificationHandler> notifications = await conn.getNotifications(CurrentUser.type, CurrentUser.ID); List <QuickViewNotif> all = new List <QuickViewNotif>(); for (int i = notifications.Count - 1; i >= 0; i--) { if (notifications[i].type.Equals("maintenance")) { all.Add(new QuickViewNotif("Maintenance request for " + notifications[i].description, "Maintenance request")); } if (notifications[i].type.Equals("updateEmployee")) { all.Add(new QuickViewNotif(notifications[i].description, "Update")); } } quickview.ItemsSource = all; quickview.RowHeight = 60; }
async void populatePage() { //Instantiates conenction object and calls method which gets notifications given a residentID DatabaseGET conn = new DatabaseGET(); List <balance> balances = await conn.getBalances(CurrentUser.ID); List <ConnectHelpers.NotificationHandler> notifications = await conn.getNotifications(CurrentUser.type, CurrentUser.ID); List <ResidentInfo> resident = await(conn.getResidentInfo(CurrentUser.ID)); String amount = (Convert.ToDouble(balances[0].amount1) + Convert.ToDouble(balances[0].amount2) + Convert.ToDouble(balances[0].amount3) + Convert.ToDouble(balances[0].amount4) + Convert.ToDouble(balances[0].bAmount)).ToString(); if (amount.Equals("0")) { balance.Text = "$0.00"; } else { balance.Text = "$" + amount; } //Sets text for room information at top of screen address.Text = resident[0].address; room.Text = resident[0].number; String roommates = ""; for (int i = 0; i < resident.Count; i++) { if (i == resident.Count - 2) { roommates += resident[i].firstName + " " + resident[i].lastName + ", & "; } else if (i == resident.Count - 1) { roommates += resident[i].firstName + " " + resident[i].lastName; } else { roommates += resident[i].firstName + " " + resident[i].lastName + ", "; } } residents.Text = roommates; //Creates list of notifications for use in UI List <QuickViewNotif> notifs = new List <QuickViewNotif>(); String first = ""; String last = ""; for (int i = notifications.Count - 1; i >= 0; i--) { if (notifications[i].type == "payRoom") { List <ResidentInfo> name = await conn.getResidentInfo(Convert.ToInt32(notifications[i].sender)); for (int j = 0; j < name.Count; j++) { if (name[j].residentID.Equals(notifications[i].sender)) { first = name[j].firstName; last = name[j].lastName; } } notifs.Add(new QuickViewNotif(first + " " + last + " paid $" + notifications[i].amount + " for '" + notifications[i].description + "'", "Roommate paid")); } if (notifications[i].type == "payBuilding") { notifs.Add(new QuickViewNotif("You paid $" + notifications[i].amount + " to owner", "Payment to building")); } if (notifications[i].type == "maintenanceScheduled") { notifs.Add(new QuickViewNotif(notifications[i].description, "Maintenance Scheduled")); } if (notifications[i].type == "fine") { notifs.Add(new QuickViewNotif("Your room was fined $" + notifications[i].amount + " for '" + notifications[i].description + "'.", "Fine")); } if (notifications[i].type == "update") { notifs.Add(new QuickViewNotif(notifications[i].description, "Update")); } if (notifications[i].type == "bought") { List <ResidentInfo> name = await conn.getResidentInfo(Convert.ToInt32(notifications[i].sender)); for (int j = 0; j < name.Count; j++) { if (name[j].residentID.Equals(notifications[i].sender)) { first = name[j].firstName; last = name[j].lastName; } } notifs.Add(new QuickViewNotif(first + " " + last + " bought '" + notifications[i].description + "' and you owe $" + notifications[i].amount, "Debt incurrence")); } } //Sets the source of the listview and the row height quickview.ItemsSource = notifs; quickview.RowHeight = 60; }