public static Player EnsurePlayerIsCreated(SoccerDataModelDataContext theContext, string facebookUserID, GetFBUserDelegate theFBUser) { var player = (from dbPlayer in theContext.Players where dbPlayer.FacebookID == facebookUserID select dbPlayer).FirstOrDefault(); if (player == null) { // Tenemos un nuevo jugador (unico punto donde se crea) player = new Player(); player.FacebookID = facebookUserID; player.CreationDate = DateTime.Now; // En horario del servidor... player.Liked = false; if (theFBUser != null) { // Probablemente llamada Rest Facebook.Schema.user theFBUSer = theFBUser(); player.Name = theFBUSer.first_name; player.Surname = theFBUSer.last_name; } else { // Queremos evitar la llamada en los Test de debug player.Name = "PlayerName"; player.Surname = "PlayerSurname"; } theContext.Players.InsertOnSubmit(player); } return player; }
protected void Page_Load(object sender, EventArgs e) { mTeamID = int.Parse(Request.QueryString["TeamID"]); mPlayer = (from p in mDC.Players where p.Team.TeamID == mTeamID select p).First(); FillProfile(); }
public static BDDModel.Session EnsureSessionIsCreated(SoccerDataModelDataContext theContext, Player thePlayer, string sessionKey) { var session = (from dbSession in theContext.Sessions where dbSession.FacebookSession == sessionKey select dbSession).FirstOrDefault(); if (session == null) { session = new BDDModel.Session(); session.Player = thePlayer; session.FacebookSession = sessionKey; session.CreationDate = DateTime.Now; // En horario del servidor theContext.Sessions.InsertOnSubmit(session); } return session; }
private SoccerDataModelDataContext CreateDataForRequest() { mContext = new SoccerDataModelDataContext(); HttpContext theCurrentHttp = HttpContext.Current; if (!theCurrentHttp.Request.QueryString.AllKeys.Contains("SessionKey")) throw new Exception("SessionKey is missing"); string sessionKey = theCurrentHttp.Request.QueryString["SessionKey"]; mSession = (from s in mContext.Sessions where s.FacebookSession == sessionKey select s).FirstOrDefault(); if (mSession == null) throw new Exception("Invalid SessionKey: " + sessionKey); mPlayer = mSession.Player; return mContext; }
private static string PlayerToString(Player player) { return "Name: " + player.Name + " " + player.Surname + " FacebookID: " + player.FacebookID; }
private void CloseOldConnectionForPlayer(Player player) { IList<NetPlug> plugs = mNetServer.GetNetPlugs(); foreach (NetPlug plug in plugs) { // Es posible que la conexión se haya desconectado o que no haya hecho login todavia... if (!plug.IsClosed && plug.UserData != null) { if ((plug.UserData as RealtimePlayer).PlayerID == player.PlayerID) { plug.Invoke("PushedDisconnected", "Duplicated"); plug.CloseRequest(); break; } } } }