Beispiel #1
0
        public bool IncrementYear()
        {
            //add a check to make sure previous year is done?
            var gameData = gameDataRepo.GetCurrentData();

            if (IsYearComplete(gameData.CurrentYear))
            {
                gameData.CurrentYear = gameData.CurrentYear + 1;
                gameData.CurrentDay  = 1;
                SetupComeptitionsForDay(gameData.CurrentDay, gameData.CurrentYear);
                gameDataRepo.Update(gameData);
                gameDataRepo.Flush();

                return(true);
            }
            else
            {
                //thow message unable to do this.

                return(false);
            }
        }
Beispiel #2
0
        public void SetupConfig(bool setupDatabase, bool dropFirst, bool setupData)
        {
            if (setupDatabase)
            {
                var session = NHibernateHelper.OpenSession();


                if (dropFirst)
                {
                    var query = session.CreateSQLQuery("exec DropAllTables");

                    query.ExecuteUpdate();

                    //D:\Visual Studio Projects\gitrepos\TeamApp\TeamApp.Test.Database\sqloutput\dropddl.sql
                }

                var configuration = NHibernateHelper.GetConfiguration().BuildConfiguration();
                var schemaExport  = new SchemaExport(configuration);
                schemaExport.Create(false, true);
            }

            if (setupData)
            {
                var gameData = new GameData();
                gameData.CurrentDay  = 1;
                gameData.CurrentYear = 1;
                gameDataRepository.Update(gameData);

                var league        = DataCreator.CreateLeague("nhl");
                var teams         = DataCreator.CreateTeams();
                var seasonConfig  = DataCreator.CreateLargeSeasonConfiguration(league, teams, null, 1, 1);
                var playoffConfig = DataCreator.CreateLargePlayoffConfiguration(league, new List <CompetitionConfig>()
                {
                    seasonConfig
                }, 2, null, 1, null);

                //var seasonConfig = DataCreator.CreateSmallSeasonConfiguration(league, teams, null, 1, 1);
                //var seasonConfig = DataCreator.CreateMediumSeasonConfig(league, teams, null, 1, 1);
                //var playoffConfig = DataCreator.CreateSmallPlayoffConfiguration(league, new List<CompetitionConfig>() { seasonConfig }, 2, null, 1, null);

                //var league = Data2.CreateBasicLeague("NHL");
                //var seasonCompetition = Data2.CreateBasicSeasonConfiguration(league);
                //var playoffCompetition = Data2.CreateBasicPlayoffConfiguration(seasonCompetition);

                leagueRepository.Update(league);
            }
        }