コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,ChallengeID,TeamID")] TeamScoreItem teamScoreItem)
        {
            if (id != teamScoreItem.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(teamScoreItem);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TeamScoreItemExists(teamScoreItem.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            ViewData["ChallengeID"] = new SelectList(_context.Challenge, "Id", "Name", teamScoreItem.ChallengeID);
            ViewData["TeamID"]      = new SelectList(_context.Team, "Id", "Name", teamScoreItem.TeamID);
            return(View(teamScoreItem));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("Id,ChallengeID,TeamID")] TeamScoreItem teamScoreItem)
        {
            if (ModelState.IsValid)
            {
                _context.Add(teamScoreItem);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewData["ChallengeID"] = new SelectList(_context.Challenge, "Id", "Name", teamScoreItem.ChallengeID);
            ViewData["TeamID"]      = new SelectList(_context.Team, "Id", "Name", teamScoreItem.TeamID);
            return(View(teamScoreItem));
        }
コード例 #3
0
        private async Task <IActionResult> UpdateChallenge(string vstsUrl, string uniqueTag, string teamname, string venuename, string status, bool helpTagFound, int workitemid)
        {
            var challenge = await _context.Challenge.SingleOrDefaultAsync(c => c.UniqueTag == uniqueTag);

            if (challenge == null)
            {
                return(BadRequest("Unknown challenge"));
            }

            var team = await _context.Team.SingleOrDefaultAsync(c => c.Name == teamname && c.Venue.Name == venuename);

            if (team == null)
            {
                var venue = await _context.Venue.SingleOrDefaultAsync(c => c.Name == venuename);

                if (venue == null)
                {
                    venue = new Venue()
                    {
                        Name = venuename
                    };
                    await _context.Venue.AddAsync(venue);
                }
                team = new Team()
                {
                    Venue = venue,
                    Name  = teamname
                };
            }

            var tsi = await _context.TeamScoreItem.SingleOrDefaultAsync(t => t.Challenge == challenge && t.Team == team);


            if (tsi == null)
            {
                tsi = new TeamScoreItem()
                {
                    Challenge = challenge,
                    Team      = team,
                    Status    = status,
                };
                await _context.TeamScoreItem.AddAsync(tsi);
            }
            else
            {
                tsi.Status = status;
            }
            if (!challenge.IsBonus)
            {
                if (!tsi.HelpUsed)
                {
                    if (helpTagFound)
                    {
                        await PatchWithHelpComment(vstsUrl, workitemid, challenge);

                        tsi.HelpUsed = true;
                    }
                }
            }
            else
            {
                if (helpTagFound)
                {
                    await PatchWithHelpNotAvailableComment(vstsUrl, workitemid);
                }
            }
            await _context.SaveChangesAsync();

            return(Accepted());
        }