예제 #1
0
        async void boughtClick(object sender, EventArgs e)
        {
            if (bought.Text.Equals(""))
            {
                await DisplayAlert("Error", "Please specify amount you bought for", "Okay");
            }
            else
            {
                //gets residents on the list
                //adds split balance to amount of roommate who clicks button
                //adds notification for user letting them know list is bought
                //deleted list from database, keeps items for suggestion purposes
                DatabaseGET            conn = new DatabaseGET();
                List <ListInformation> list = await conn.getLists(listID);

                List <String> roommateIDs = new List <string>();
                if (list[0].residentID1 != null && !list[0].residentID1.Equals(CurrentUser.ID + ""))
                {
                    roommateIDs.Add(list[0].residentID1);
                }
                if (list[0].residentID2 != null && !list[0].residentID2.Equals(CurrentUser.ID + ""))
                {
                    roommateIDs.Add(list[0].residentID2);
                }
                if (list[0].residentID3 != null && !list[0].residentID3.Equals(CurrentUser.ID + ""))
                {
                    roommateIDs.Add(list[0].residentID3);
                }
                if (list[0].residentID4 != null && !list[0].residentID4.Equals(CurrentUser.ID + ""))
                {
                    roommateIDs.Add(list[0].residentID4);
                }
                String       purchaseAmount = (Convert.ToDouble(amount.Text) / (roommateIDs.Count + 1)).ToString();
                DatabasePOST conn2          = new DatabasePOST();

                await conn2.chargeAllAndNotify(purchaseAmount, CurrentUser.ID + "", roommateIDs, listID, listName.Text);

                //NotificationHandler notifications = new NotificationHandler();
                //notifications.send(amount, "1", roommateIDs, listID, listName.Text);
                await DisplayAlert("Success", "Purchase recorded and roommate(s) notified", "OK");

                await Navigation.PushModalAsync(new Resident());
            }
        }
예제 #2
0
        async void populateLists()
        {
            DatabaseGET conn = new DatabaseGET();

            lists = await conn.getLists(CurrentUser.ID);

            //List which will come from database with all the list items and information
            list = new List <ListInfo>();
            List <int> added = new List <int>();

            for (int i = 0; i < lists.Count; i++)
            {
                if (lists[i].residentID1 != null && lists[i].residentID2 != null && lists[i].residentID3 != null && lists[i].residentID4 != null && !added.Contains(Convert.ToInt32(lists[i].listID)))
                {
                    list.Add(new ListInfo(lists[i].listName, await conn.getName(lists[i].residentID1) + ", " + await conn.getName(lists[i].residentID2) + ", " + await conn.getName(lists[i].residentID3) + ", & " + await conn.getName(lists[i].residentID4), lists[i].listID));
                    added.Add(Convert.ToInt32(lists[i].listID));
                }
                else if (lists[i].residentID1 != null && lists[i].residentID2 != null && lists[i].residentID3 != null && !added.Contains(Convert.ToInt32(lists[i].listID)))
                {
                    list.Add(new ListInfo(lists[i].listName, await conn.getName(lists[i].residentID1) + ", " + await conn.getName(lists[i].residentID2) + ", & " + await conn.getName(lists[i].residentID3), lists[i].listID));
                    added.Add(Convert.ToInt32(lists[i].listID));
                }
                else if (lists[i].residentID1 != null && lists[i].residentID2 != null && !added.Contains(Convert.ToInt32(lists[i].listID)))
                {
                    list.Add(new ListInfo(lists[i].listName, await conn.getName(lists[i].residentID1) + " & " + await conn.getName(lists[i].residentID2), lists[i].listID));
                    added.Add(Convert.ToInt32(lists[i].listID));
                }
                else if (!added.Contains(Convert.ToInt32(lists[i].listID)))
                {
                    list.Add(new ListInfo(lists[i].listName, await conn.getName(lists[i].residentID1), lists[i].listID));
                    added.Add(Convert.ToInt32(lists[i].listID));
                }
            }

            allLists.ItemsSource = list;
            allLists.RowHeight   = 60;
        }