Пример #1
0
        private void ShowElectionResults()
        {
            var listOfCandidates = webApiService.GetListOfCandidates();
            int sumOfVotes       = GetSumOfVotes(listOfCandidates);

            if (sumOfVotes == 0)
            {
                Console.WriteLine("Nobody has voted yet.");
            }
            else
            {
                foreach (Candidate candidate in listOfCandidates)
                {
                    double percentageResult = Math.Round((100f * candidate.Votes / sumOfVotes));
                    Console.WriteLine($"{candidate.Id}. {candidate.LastName} {candidate.FirstName} [ Votes: {candidate.Votes}, (percent of total: {percentageResult}%) ]");
                }
            }
        }
Пример #2
0
 private List <Candidate> GetListOfCandidates()
 {
     return(webApiService.GetListOfCandidates());
 }