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
        async Task displayGemAndRank()
        {
            var ratingsTable = await tableManager.GetRatingsAsync();

            var itemsTable = await tableManager.GetBoardgamesAsync();

            int lendCount = itemsTable.Where(item => String.Equals(profOwner.UserId, item.Owner)).Count();
            var ratings   = ratingsTable.Where(r => String.Equals(profOwner.UserId, r.RatedID)).Select(rating => rating.Rating);

            double avgRatings;
            string rank;

            if (ratings.Count() > 0)
            {
                avgRatings = ratings.Average();
            }
            else
            {
                avgRatings = 0;
            }


            if (lendCount > 0 && lendCount < 3)
            {
                rank       = "Amber";
                Gem.Source = "Gem3.png";
            }
            else if (lendCount >= 3 && lendCount < 10 && avgRatings >= 3)
            {
                rank       = "Emerald";
                Gem.Source = "Gem5.png";
            }
            else if (lendCount >= 10 && lendCount < 25 && avgRatings >= 4)
            {
                rank       = "Amethyst";
                Gem.Source = "Gem9.png";
            }
            else if (lendCount >= 25 && avgRatings >= 4.5)
            {
                rank       = "Diamond";
                Gem.Source = "Gem8.png";
            }
            else
            {
                rank       = "Topaz";
                Gem.Source = "Gem6.png";
            }

            Rank.Text = String.Format("Rank:  {0}", rank);
        }
Exemplo n.º 3
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;
        }
Exemplo n.º 4
0
        public async void OnSearch(object sender, EventArgs e)
        {
            var boardGamesTable = await manager.GetBoardgamesAsync();

            string sid = await App.Authenticator.GetUserId();

            var results = boardGamesTable.Where(b => (!String.Equals(b.Owner, sid)) && (String.Equals(b.Name, searchBar.Text, StringComparison.CurrentCultureIgnoreCase)) && b.Borrowed == false);

            if (results.Count() > 0)
            {
                resultList.ItemsSource = results;
            }
            else
            {
                await DisplayAlert("No results found", searchBar.Text + " is currently not available", "Cancel");
            }
        }
Exemplo n.º 5
0
        async void updateDetails(bool isItem)
        {
            string name;

            if (isItem)
            {
                var itemsTable = await manager.GetBoardgamesAsync();

                name = itemsTable.Where(item => string.Equals(reviewedEntityID, item.Id)).Select(col => col.Name).ElementAt(0);
            }
            else
            {
                var usersTable = await manager.GetUserAsync();

                User user = usersTable.Where(u => string.Equals(reviewedEntityID, u.UserId)).ElementAt(0);
                name = String.Format("{0} {1}", user.FirstName, user.LastName);
            }
            pageTitle.Text      = "Reviews for " + name;
            overallRating.Value = await getOverallRating();
        }