Ejemplo n.º 1
0
        public async Task <IActionResult> IssuePass(CandidatePass pass)
        {
            User user = await _context.Users.FindAsync(pass.UserId);

            if (user == null)
            {
                StatusMessage = $"Error: Failed to find user with ID {pass.UserId}";
                return(View());
            }

            pass.Id = Guid.NewGuid().ToString();

            await _context.CandidatePasses.AddAsync(pass);

            await _context.SaveChangesAsync();

            if (!pass.Blacklist)
            {
                StatusMessage = $"Successfully issued candidate pass.";

                EmbedBuilder embed = new EmbedBuilder()
                {
                    Color = new Color(0, 100, 255),
                    Title = $"**{user.Name}** Granted a candidacy pass!"
                }
                .WithCurrentTimestamp();

                embed.AddField("News Outlet", "VoopAI Auto News");
                embed.AddField("Author", "VoopAI The Bot");
                embed.AddField("Content", $"The candidate {user.Name} appears to have been given special access to run in the " +
                               $"{pass.District} {pass.Type} elections! We expect other stations to report on this development soon. This " +
                               $"makes it very likely this candidate will be running in future races.");

                VoopAI.newsChannel.SendMessageAsync(embed: embed.Build());
            }
            else
            {
                StatusMessage = $"Successfully issued candidate blacklist.";

                EmbedBuilder embed = new EmbedBuilder()
                {
                    Color = new Color(0, 100, 255),
                    Title = $"**{user.Name}** Blocked from election!"
                }
                .WithCurrentTimestamp();

                embed.AddField("News Outlet", "VoopAI Auto News");
                embed.AddField("Author", "VoopAI The Bot");
                embed.AddField("Content", $"The candidate {user.Name} appears to have been removed from the running in " +
                               $"{pass.District} {pass.Type} elections! We expect other stations to report on this development soon. This " +
                               $"effectively bars them from the Senate.");

                VoopAI.newsChannel.SendMessageAsync(embed: embed.Build());
            }

            return(RedirectToAction("ManageElections"));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> IssuePass()
        {
            CandidatePass pass = new CandidatePass();

            return(View(pass));
        }