public void RemoveUserFromTeam(PgUser user, PgTeam team)
 {
     if ((user.Team == null) || (team == null) || (team.Temporarily == false))
         return;
     var url = _userData.PgSession.GetWebAppFunction("/api", "/users/" + user.Id + "/remove_from_team", "team_id=" + team.Id);
     var client = new RestSharp.RestClient(url);
     var request = new RestSharp.RestRequest(RestSharp.Method.GET) { RequestFormat = RestSharp.DataFormat.Json };
     RestSharp.RestResponse<PgTeam> response = (RestSharp.RestResponse<PgTeam>)client.Execute<PgTeam>(request);
     if (response.IsOk() == true)
     {
         user.Team = response.Data;
     }
 }
 private void LoadTeamBot()
 {
     var url = UserDataManager.UserData.PgSession.GetWebAppFunction("/api", "/game_rooms/" + this._session.GameRoom.Id + "/team_bot");
     var client = new RestSharp.RestClient(url);
     var request = new RestSharp.RestRequest(RestSharp.Method.GET) { RequestFormat = RestSharp.DataFormat.Json };
     RestSharp.RestResponse response = (RestSharp.RestResponse)client.Execute(request);
     var result = Newtonsoft.Json.Linq.JObject.Parse(response.Content);
     if (((Newtonsoft.Json.Linq.JProperty)result.First).Name != "errors")
     {
         var teamBot = new PgUser();
         var name = ((Newtonsoft.Json.Linq.JProperty)result.First).Value.ToString();
         var team = new PgTeam();
         team.Name = GameRoomWindowModelView.TeamBotGroupName;
         teamBot.Id = "bot_" + name;
         teamBot.Username = name;
         teamBot.Points = Convert.ToInt32(((Newtonsoft.Json.Linq.JProperty)result.First.Next).Value.ToString());
         teamBot.Team = team;
         _session.GameRoom.TeamBot = teamBot;
         _session.GameRoom.IsTeamBotPlaced = true;
     }
     else
         _session.GameRoom.IsTeamBotPlaced = false;
 }
        public PgTeam GetPgTeam(TeamBase teamBase)
        {
            if (teamBase == null || teamBase._id == null)
                return null;

            PgTeam team;
            if (!_teamLookup.TryGetValue(teamBase._id, out team))
            {
                team = new PgTeam { Id = teamBase._id, Name = teamBase.name };
                _teamLookup[teamBase._id] = team;
            }
            var teamFull = teamBase as TeamFull;
            if (teamFull != null)
            {
                team.Name = teamFull.name;
                team.Temporarily = teamFull.temporarily;
                // todo copy the rest of the details
            }

            return team;
        }