Пример #1
0
        private static int CreateDatabaseMatch(SoccerDataModelDataContext theContext, RealtimePlayer homeRT, RealtimePlayer awayRT)
        {
            BDDModel.Match theNewMatch = new BDDModel.Match();
            theNewMatch.DateStarted = DateTime.Now;

            BDDModel.MatchParticipation homePart = CreateMatchParticipation(theContext, homeRT, true);
            BDDModel.MatchParticipation awayPart = CreateMatchParticipation(theContext, awayRT, false);

            homePart.Match = theNewMatch;
            awayPart.Match = theNewMatch;

            theContext.MatchParticipations.InsertOnSubmit(homePart);
            theContext.MatchParticipations.InsertOnSubmit(awayPart);

            theContext.Matches.InsertOnSubmit(theNewMatch);
            theContext.SubmitChanges();

            homeRT.MatchParticipationID = homePart.MatchParticipationID;
            awayRT.MatchParticipationID = awayPart.MatchParticipationID;

            return theNewMatch.MatchID;
        }
Пример #2
0
        private void ProcessInFacebookSessionUser()
        {
            using (SoccerDataModelDataContext theContext = new SoccerDataModelDataContext())
            {
                Player player = EnsurePlayerIsCreated(theContext, Api.Session.UserId.ToString(), () => Api.Users.GetInfo() );

                string sessionKey = Request.Form["fb_sig_session_key"];

                if (sessionKey != null)
                {
                    EnsureSessionIsCreated(theContext, player, sessionKey);
                    theContext.SubmitChanges();

                    string queryStringToClient = Request.Form.ToString();

                    if (player.Liked)
                        queryStringToClient += "&liked=true";

                    // Seria mejor hacer un transfer, pero no sabemos como librarnos de la exception, a pesar del catch parece que la relanza??
                    Response.Redirect("SoccerClientV1/SoccerClientV1.html?" + queryStringToClient, false);
                }
                else
                {
                    ProcessSessionError("No session key");
                }
            }
        }
Пример #3
0
        internal RealtimeMatchResult OnFinishMatch(RealtimeMatch realtimeMatch)
        {
            RealtimeMatchResult matchResult = null;

            RealtimePlayer player1 = realtimeMatch.GetRealtimePlayer(RealtimeMatch.PLAYER_1);
            RealtimePlayer player2 = realtimeMatch.GetRealtimePlayer(RealtimeMatch.PLAYER_2);

            using (SoccerDataModelDataContext theContext = new SoccerDataModelDataContext())
            {
                Player bddPlayer1 = GetPlayerForRealtimePlayer(theContext, player1);
                Player bddPlayer2 = GetPlayerForRealtimePlayer(theContext, player2);

                // Los BDDPlayers se actualizan dentro de la funcion (... old GiveMatchRewards)
                matchResult = new RealtimeMatchResult(theContext, realtimeMatch, bddPlayer1, bddPlayer2);

                // Actualizacion del BDDMatch...
                BDDModel.Match theBDDMatch = (from m in theContext.Matches
                                                where m.MatchID == realtimeMatch.MatchID
                                                select m).FirstOrDefault();

                theBDDMatch.DateEnded = DateTime.Now;
                theBDDMatch.WasTooManyTimes = matchResult.WasTooManyTimes;
                theBDDMatch.WasJust = matchResult.WasJust;
                theBDDMatch.WasAbandoned = matchResult.WasAbandoned;
                theBDDMatch.WasAbandonedSameIP = matchResult.WasAbandonedSameIP;

                // ... y de las MatchParticipations de la BDD
                (from p in theContext.MatchParticipations
                    where p.MatchParticipationID == player1.MatchParticipationID
                    select p).FirstOrDefault().Goals = matchResult.GetGoalsFor(player1);

                (from p in theContext.MatchParticipations
                    where p.MatchParticipationID == player2.MatchParticipationID
                    select p).FirstOrDefault().Goals = matchResult.GetGoalsFor(player2);

                theContext.SubmitChanges();
            }

            player1.PlayerData = null;
            player2.PlayerData = null;
            player1.MatchParticipationID = -1;
            player2.MatchParticipationID = -1;
            player1.TheMatch = null;
            player2.TheMatch = null;

            // Borramos el match, dejamos que ellos se unan a la habitacion
            mMatches.Remove(realtimeMatch);

            return matchResult;
        }