Ejemplo n.º 1
0
        public Game GetGame(int gameId, bool populateTeams)
        {
            var thisGame = CBO.FillObject <Game>(DataProvider.Instance().GetGame(gameId));

            if (thisGame != null)
            {
                if (populateTeams)
                {
                    var tc = new TeamController();
                    foreach (Team t in tc.GetTeamsByGame(thisGame.GameId))
                    {
                        thisGame.Teams.Add(t);
                    }
                }
            }
            return(thisGame);
        }
Ejemplo n.º 2
0
        ///<summary>Take a list of Games and populate the Teams
        ///</summary>
        private static List <Game> PopulateTeamsForGame(IEnumerable <Game> games)
        {
            var outputGames = new List <Game>();

            foreach (var log in games)
            {
                //get the teams
                var tc = new TeamController();
                foreach (Team t in tc.GetTeamsByGame(log.GameId))
                {
                    log.Teams.Add(t);
                }
                outputGames.Add(log);
                //get the players
            }

            return(outputGames);
        }
Ejemplo n.º 3
0
        /* create game workflow */

        //save game
        public Game SaveGame(Game g)
        {
            bool newGame = !(g.GameId > 0);

            g = g.GameId > 0 ? UpdateGame(g) : CreateGame(g);

            if (!newGame)
            {
                //clear game/team records first? then update to handle change of team ids?
                DataProvider.Instance().DeleteGameTeams(g.GameId);
            }

            foreach (var t in g.Teams)
            {
                var tc = new TeamController();
                //configure the portalId
                t.PortalId   = g.PortalId;
                t.LastPlayed = DateTime.Now;
                t.TeamId     = tc.SaveTeam(t).TeamId;
                //add GameTeam relationship to store the Scores
                //TODO: figure out how to track wins with a dynamic score total
                bool win = t.Score >= 5;

                //TODO: figure out how to flag a WIN and HOME team
                if (newGame)
                {
                    DataProvider.Instance().AddGameTeam(g.GameId, t.TeamId, t.Score, win, t.HomeTeam);
                }
                else
                {
                    DataProvider.Instance().AddGameTeam(g.GameId, t.TeamId, t.Score, win, t.HomeTeam);
                }
            }

            return(g);
        }
Ejemplo n.º 4
0
        public Team Save()
        {
            var tc = new TeamController();

            return(tc.SaveTeam(this));
        }