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)); }
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)); }
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)); }