예제 #1
0
        public async Task End()
        {
            if (_votingService.VotingOpen())
            {
                Console.WriteLine("Ending voting session");
                _votingService.EndVote();

                var results = _votingService.GetResults(_nominationsService.GetNominations());
                _votingService.ClearResults();
                _nominationsService.ClearNominations();

                var sb = new StringBuilder();
                sb.AppendLine("Voting has ended! The results: ");

                foreach (var res in results)
                {
                    sb.AppendLine($"{res.Movie.Name}: {res.Votes}");
                }

                var winner = _votingService.GetWinner(results);

                sb.AppendLine($"The winner is: {winner.Movie.Name}");

                await ReplyAsync(sb.ToString());

                var movie = await _omdbService.GetMovieById(winner.Movie.ImdbId);
                await ReplyAsync(movie.ToString());
            }
            else
            {
                await ReplyAsync($"There is no vote in progress");
            }
        }