Ejemplo n.º 1
0
        public async Task InfoById(string id)
        {
            var movie = await _omdbService.GetMovieById(id);

            Console.WriteLine($"Retrieved movie info for id={movie.ImdbId}");
            await ReplyAsync(movie.ToString());
        }
Ejemplo n.º 2
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");
            }
        }
Ejemplo n.º 3
0
        public async Task NominateById(string id)
        {
            Console.WriteLine($"Got nomination request for {id}");
            if (!_votingService.VotingOpen())
            {
                var mov = await _omdbService.GetMovieById(id);

                if (mov.Title.Equals(null))
                {
                    Console.WriteLine($"Failed to find nominated movie {id}");
                    await ReplyAsync("Could not find this movie.");
                }
                else
                {
                    if (!_nominationsService.IsNominated(mov.ImdbId))
                    {
                        Console.WriteLine($"Adding nominated movie \"{id}\"");
                        await ReplyAsync(mov.ToString());

                        // If this isnt the right one, specify the year and change the nomination
                        _nominationsService.AddNomination(Context.User, mov.Title, mov.ImdbId);
                        await ReplyAsync("Thanks for nominating!");
                    }
                    else
                    {
                        Console.WriteLine($"Attempted to nominate duplicate movie \"{id}\"");
                        await ReplyAsync($"{mov.Title} is already nominated!");
                    }
                }
            }
            else
            {
                await ReplyAsync("Cannot nominate during open voting session");
            }
        }