public async Task <IActionResult> Create([Bind("Id,Name,City,bestPlayer")] Teams teams) { if (ModelState.IsValid) { _context.Add(teams); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(teams)); }
public async Task <IActionResult> AddOrEdit([Bind("TeamsId,TeamName,LeaderName,CallNumber,TeamLocation")] Teams teams) { if (ModelState.IsValid) { if (teams.TeamsId == 0) { _context.Add(teams); } else { _context.Update(teams); } await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(teams)); }
public async Task DeleteTeamAsync(int teamId) { _context.Teams.Remove(new Team { Id = teamId }); try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if ((await _context.Teams .SingleOrDefaultAsync(e => e.Id == teamId)) == null) { throw new Exception("Team not found"); } else { throw; } } }