public IActionResult VoegWedstrijdToe(Wedstrijd wedstrijd) { int i = 1; for (int j = 0; j < _context.Wedstrijden.Count(); j++) { List <Wedstrijd> lijst = _context.Wedstrijden.ToList(); if (i == lijst[j].ID) { i++; } else { break; } } if (ModelState.IsValid) { try { wedstrijd.ID = i; _context.Add(wedstrijd); _context.SaveChanges(); } catch (DbUpdateConcurrencyException) { throw; } return(RedirectToAction("Index", "Maintain")); } return(View(wedstrijd)); }
public IActionResult VoegSpelerToe(Speler speler) { int i = 1; for (int j = 0; j < _context.Spelers.Count(); j++) { List <Speler> lijst = _context.Spelers.ToList(); if (i == lijst[j].ID) { i++; } else { break; } } if (ModelState.IsValid) { try { speler.ID = i; _context.Add(speler); _context.SaveChanges(); } catch (DbUpdateConcurrencyException) { throw; } return(RedirectToAction("ListSpelers", new { id = speler.TeamID })); } return(View(speler)); }