예제 #1
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);
        }
예제 #2
0
        public Team Save()
        {
            var tc = new TeamController();

            return(tc.SaveTeam(this));
        }