public async Task <IActionResult> Edit(int id, [Bind("PlayersPositionsId,PlayersId,PositionsId")] PlayersPositions playersPositions) { if (id != playersPositions.PlayersPositionsId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(playersPositions); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PlayersPositionsExists(playersPositions.PlayersPositionsId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["PlayersId"] = new SelectList(_context.Players, "PlayersId", "PlayersName", playersPositions.PlayersId); ViewData["PositionsId"] = new SelectList(_context.Positions, "PositionsId", "PositionsName", playersPositions.PositionsId); return(View(playersPositions)); }
public async Task <IActionResult> Create([Bind("PlayersPositionsId,PlayersId,PositionsId")] PlayersPositions playersPositions) { if (ModelState.IsValid) { _context.Add(playersPositions); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["PlayersId"] = new SelectList(_context.Players, "PlayersId", "PlayersName", playersPositions.PlayersId); ViewData["PositionsId"] = new SelectList(_context.Positions, "PositionsId", "PositionsName", playersPositions.PositionsId); return(View(playersPositions)); }