public async Task <IActionResult> Edit(int id, [Bind("Id,Name,WinnerId")] Tournament tournament)
        {
            if (id != tournament.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(tournament);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TournamentExists(tournament.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["WinnerId"] = new SelectList(_context.Player, "Id", "Id", tournament.WinnerId);
            return(View(tournament));
        }
示例#2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Rating,Victories,Fails")] Player player)
        {
            if (id != player.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(player);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PlayerExists(player.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(player));
        }
示例#3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Date,Player1Id,Player2Id,TournamentId")] Game game)
        {
            if (id != game.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(game);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GameExists(game.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Player1Id"]    = new SelectList(_context.Player, "Id", "Id", game.Player1Id);
            ViewData["Player2Id"]    = new SelectList(_context.Player, "Id", "Id", game.Player2Id);
            ViewData["TournamentId"] = new SelectList(_context.Set <Tournament>(), "Id", "Id", game.TournamentId);
            return(View(game));
        }