예제 #1
0
        public async Task InfoByYear(string movieName, int year)
        {
            var movie = await _omdbService.GetMovieByTitleYear(movieName, year);

            Console.WriteLine($"Retrieved movie info for \"{movieName}\", {year}; id={movie.ImdbId}");
            await ReplyAsync(movie.ToString());
        }
예제 #2
0
        public async Task AddNominationWithYearASync(string name, int year)
        {
            Console.WriteLine($"Got nomination request for \"{name}\", {year}");
            if (!_votingService.VotingOpen())
            {
                var movie = await _omdbService.GetMovieByTitleYear(name, year);

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

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