public async Task <IActionResult> Edit(int id, [Bind("ID,Name")] BaseballLeague baseballLeague) { if (id != baseballLeague.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _db.Update(baseballLeague); await _db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BaseballLeagueExists(baseballLeague.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(baseballLeague)); }
public async Task <IActionResult> Create([Bind("ID,Name")] BaseballLeague baseballLeague) { if (ModelState.IsValid) { _db.Add(baseballLeague); await _db.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(baseballLeague)); }
public static BaseballLeague[] GetData() { var baseballLeague = new BaseballLeague[] { new BaseballLeague { Name = "American League" }, new BaseballLeague { Name = "National League" } }; return(baseballLeague); }