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());
        }
Пример #2
0
        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));
        }