Пример #1
0
        private async Task RefreshItems(bool showActivityIndicator, bool syncItems)
        {
            var reviews = await manager.GetRatingsAsync();

            var entityReviews = reviews.Where(r => string.Equals(r.RatedID, reviewedEntityID));
            var usersTable    = await manager.GetUserAsync();

            foreach (Ratings rating in entityReviews)
            {
                User reviewingUser = usersTable.Where(u => string.Equals(rating.ReviewerID, u.UserId)).ElementAt(0);
                rating.Reviewer = String.Format("{0} {1}", reviewingUser.FirstName, reviewingUser.LastName);
            }
            allReviews.ItemsSource = entityReviews;
        }
Пример #2
0
        // Calculating average rating from all ratings received by item
        async Task <double> getOverallRating()
        {
            var ratingsTable = await manager.GetRatingsAsync();

            var ratings = ratingsTable.Where(r => String.Equals(item.Id, r.RatedID)).Select(rating => rating.Rating);

            if (ratings.Count() > 0)
            {
                return(ratings.Average());
            }
            else
            {
                return(0);
            }
        }
Пример #3
0
        async Task <double> getUserRating()
        {
            var ratingsTable = await tableManager.GetRatingsAsync();

            var ratings = ratingsTable.Where(r => String.Equals(profOwner.UserId, r.RatedID)).Select(rating => rating.Rating);

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