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}%) ]"); } } }
private List <Candidate> GetListOfCandidates() { return(webApiService.GetListOfCandidates()); }