public async Task <IActionResult> Edit(int id, [Bind("ID,Name,CurrentAverage")] Bowler bowler) { if (id != bowler.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(bowler); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BowlerExists(bowler.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(bowler)); }
public async Task <IActionResult> Create([Bind("ID,Name,CurrentAverage")] Bowler bowler, int leagueId) { if (ModelState.IsValid) { bowler.League = _context.League.Find(leagueId); _context.Add(bowler); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(bowler)); }