public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Age,Position,TeamId")] 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))); } ViewData["TeamId"] = new SelectList(_context.Teams, "Id", "Id", player.TeamId); return(View(player)); }