Ejemplo n.º 1
0
        private static void CalculateTotalStats(VoteStatsViewModel viewModel, IEnumerable <Vote> votes, IEnumerable <Player> allPlayers)
        {
            viewModel.NumberOfVotes = votes.Count();
            viewModel.PercentageOfVotesOntoMafia =
                VoteAnalyser.CalculatePercentage(votes, (v) => v.TargetAllegiance == Allegiance.Mafia, allPlayers);

            viewModel.PercentageOfVotesOntoTown =
                VoteAnalyser.CalculatePercentage(votes, (v) => v.TargetAllegiance == Allegiance.Town, allPlayers);

            viewModel.PercentageOfVotesOntoNonTown =
                VoteAnalyser.CalculatePercentage(votes, (v) => v.TargetAllegiance != Allegiance.Town, allPlayers);
        }
Ejemplo n.º 2
0
        public ActionResult Index()
        {
            VoteStatsViewModel viewModel = new VoteStatsViewModel();

            var meaningfulVotes = this.repo.FindAllValidNonUnotes();
            var allPlayers      = this.repo.FindAllPlayers();

            var meaningfulVoteGroups = meaningfulVotes.GroupBy(v => new { v.Voter, v.Recipient, v.Day });
            var votes = meaningfulVoteGroups.Select(g => g.First());

            CalculateTotalStats(viewModel, votes, allPlayers);

            viewModel.IndividualVoteStats = CalculateIndividualStats(votes, allPlayers);

            viewModel.FactionVoteStats = CalculateFactionStats(votes, allPlayers);

            return(this.View(viewModel));
        }