Exemplo n.º 1
0
        async Task displayLendBorrowCount()
        {
            var requestTable = await tableManager.GetRequestAsync();

            var itemsTable = await tableManager.GetBoardgamesAsync();

            int lendCount   = requestTable.Count(req => String.Equals(sid, req.Lender) && String.Equals(req.Accepted, "Returned"));
            int borrowCount = requestTable.Count(user => String.Equals(sid, user.Borrower));

            LendBorrow.Text = String.Format("L:{0} | B:{1}", lendCount, borrowCount);
        }
Exemplo n.º 2
0
        private async Task RefreshItems(bool showActivityIndicator, bool syncItems)
        {
            string sid = await App.Authenticator.GetUserId();

            var reqs = await tableManager.GetRequestAsync(syncItems);

            var games = await tableManager.GetBoardgamesAsync(syncItems);

            var users = await tableManager.GetUserAsync(syncItems);

            var lenderAcceptedRequests = reqs.Where(r => (String.Equals(r.Lender, sid)) && (r.Accepted.Equals("True")));
            var borrowAcceptedRequests = reqs.Where(r => (String.Equals(r.Borrower, sid)) && (r.Accepted.Equals("True")));

            List <RequestMessage> borrows = new List <RequestMessage>();
            List <RequestMessage> lends   = new List <RequestMessage>();

            string requestType   = "Lend Request";
            string requestStatus = "Accepted";
            string col           = "#00cc00";
            string seenUnseenCol = "#E0E0E0";

            foreach (Request r in lenderAcceptedRequests)
            {
                User       borrowingUser   = users.Where(user => String.Equals(r.Borrower, user.UserId)).ElementAt(0);
                Boardgames requestedItem   = games.Where(game => String.Equals(r.ItemId, game.Id)).ElementAt(0);
                string     notifView       = String.Format("{0}", requestedItem.Name);
                string     notifViewDetail = String.Format(" ");

                if (borrowingUser.UserId == Receiver.UserId)
                {
                    lends.Add(new RequestMessage(requestedItem, borrowingUser, requestType, requestStatus, r.UpdatedAt, notifView, notifViewDetail, col, seenUnseenCol, r));
                }
            }

            requestType   = "Borrow Request";
            requestStatus = "Accepted";

            foreach (Request r in borrowAcceptedRequests)
            {
                User       lendingUser     = users.Where(user => String.Equals(r.Lender, user.UserId)).ElementAt(0);
                Boardgames requestedItem   = games.Where(game => String.Equals(r.ItemId, game.Id)).ElementAt(0);
                string     notifView       = String.Format("{0}", requestedItem.Name);
                string     notifViewDetail = String.Format(" ");

                if (lendingUser.UserId == Receiver.UserId)
                {
                    borrows.Add(new RequestMessage(requestedItem, lendingUser, requestType, requestStatus, r.UpdatedAt, notifView, notifViewDetail, col, seenUnseenCol, r));
                }
            }

            borrowList.ItemsSource = borrows;
            lendList.ItemsSource   = lends;
        }