public async Task <FlowSnake> CreateAnnouncement(Announcement announcement)
        {
            announcement.Id = FlowSnake.Generate();
            db.Announcements.Add(announcement);
            await db.SaveChangesAsync();

            return(announcement.Id);
        }
Exemple #2
0
 public async Task InitializeProfileIfNotExists(string username)
 {
     if (await db.Profiles.AnyAsync(p => p.Username == username))
     {
         return;
     }
     db.Profiles.Add(new Profile()
     {
         Username = username
     });
     await db.SaveChangesAsync();
 }
        public async Task <JudgerEntry> RegisterJudger(
            string registerToken,
            string?alternateName,
            List <string>?tags)
        {
            var judgerToken = await accountService.GetJudgerRegisterToken(registerToken);

            if (judgerToken == null)
            {
                throw new KeyNotFoundException("No such token was found");
            }

            var judgerAccessToken = AccountService.GenerateToken();
            var judger            = new JudgerEntry {
                Id                 = judgerAccessToken,
                AlternateName      = alternateName,
                Tags               = tags,
                AcceptUntaggedJobs = true
            };

            db.Judgers.Add(judger);
            await db.SaveChangesAsync();

            return(judger);
        }
Exemple #4
0
        public async Task <ActionResult> SetTestSuiteVisibility(
            [FromRoute] FlowSnake suiteId,
            [FromQuery] bool visible
            )
        {
            var original = await db.TestSuites.Where(t => t.Id == suiteId).SingleOrDefaultAsync();

            if (original == null)
            {
                return(NotFound(new ErrorResponse("no_such_suite")));
            }

            original.IsPublic = visible;
            await db.SaveChangesAsync();

            return(NoContent());
        }