public IActionResult OnGet() { PlayerCollection playerCollection = new PlayerCollection(); TeamCollection teamCollection = new TeamCollection(); try { playerCollection.GetAllPlayers(); teamCollection.GetAllTeams(); } catch (MySqlException e) { var code = e.ErrorCode; if (code == -2147467259) { return(RedirectToPage("/DatabaseConnectionError")); } else { return(RedirectToPage("/Error")); } } finally { Players = playerCollection.GetPlayers(); Teams = teamCollection.GetTeams(); } return(Page()); }
public ActionResult IndexViewModel() { ViewModel model = new ViewModel(); PlayerCollection playerCollection = new PlayerCollection(); TeamCollection teamCollection = new TeamCollection(); playerCollection.GetAllPlayers(); teamCollection.GetAllTeams(); model.Players = playerCollection.GetPlayers(); model.Teams = teamCollection.GetTeams(); return(View(model)); }