Esempio n. 1
0
        /// <summary>
        /// Get the user with the most comments, looping through each comment in each game and keeping a count
        /// </summary>
        /// <param name="games"></param>
        /// <returns></returns>
        public string GetUserWithMostComments(List <Game> games)
        {
            //Keep the count of each user and the amount of comments added by the user
            Dictionary <string, int> userAndCommentCount = new Dictionary <string, int>();

            foreach (Game game in context.Get())
            {
                //Go through each comment in each game
                foreach (Comment comment in game.gameDetails.comments)
                {
                    string user = comment.user;
                    //If the user has been encountered already, just increment the count
                    if (userAndCommentCount.ContainsKey(user))
                    {
                        int value = userAndCommentCount[user];
                        userAndCommentCount[user] = value + 1;
                    }
                    else
                    {
                        //Create a new user
                        userAndCommentCount.Add(user, 1);
                    }
                }
            }

            //Sort by descending and retrieve the first value
            var ordered = userAndCommentCount.OrderByDescending(x => x.Value).FirstOrDefault().Key;

            return(ordered);
        }
Esempio n. 2
0
        //Generates a complete report using the list of average report.
        public ReportComplete GenerateReport()
        {
            ReportComplete report = new ReportComplete();

            report.highest_rated_game      = gameRetrievalService.RetrieveByHighestSumOfLikes().gameDetails.title;
            report.user_with_most_comments = gameRetrievalService.GetUserWithMostComments(_mongoDbContext.Get());
            report.average_likes_per_game  = GenerateAllAvgReport();
            return(report);
        }
Esempio n. 3
0
        public IEnumerable <Task> Get()
        {
            var tasks = _mongoDbContext.Get();

            return(tasks);
        }