public IActionResult OnPostAsync(int id) { TeamCollection teamCollection = new TeamCollection(); try { DisplayTeam = teamCollection.ReadTeam(id); teamCollection.DeleteTeam(DisplayTeam); } catch (MySqlException e) { var code = e.ErrorCode; if (code == -2147467259) { return(RedirectToPage("/DatabaseConnectionError")); } else { return(RedirectToPage("/Error")); } } finally { DisplayTeam = teamCollection.ReadTeam(id); } return(RedirectToPage("/Team")); }