public EffModel getEff(int id)
 {
     if (id > -1)
     {
         EffModel ef    = new EffModel();
         int      limit = 5;
         nbaDatabaseConnection.Open();
         query = "SELECT * FROM Actions WHERE PlayerId =" + id + " ORDER by PlayerId DESC LIMIT " + limit;
         MySqlCommand    commandDatabase = new MySqlCommand(query, nbaDatabaseConnection);
         MySqlDataReader reader          = commandDatabase.ExecuteReader();
         if (reader.HasRows)
         {
             int points = 0;
             int eff    = 0;
             while (reader.Read())
             {
                 points += reader.GetInt32(20);
                 eff    += pMC.playerEff(points, reader.GetInt32(13), reader.GetInt32(14), reader.GetInt32(16), reader.GetInt32(18), reader.GetInt32(5) - reader.GetInt32(4), reader.GetInt32(9) - reader.GetInt32(8), reader.GetInt32(17));
             }
             ef.ID  = id;
             ef.Pts = points / limit;
             ef.Eff = eff / limit;
         }
         nbaDatabaseConnection.Close();
         return(ef);
     }
     else
     {
         return(null);
     }
 }
 public void addPlayerInfo(EffModel player)
 {
     if (player != null)
     {
         databaseConnection.Open();
         query = "INSERT INTO playerinfo(id, playerId, points, eff) VALUES (NULL," + player.ID + "," + player.Pts + "," + player.Eff + ")";
         MySqlCommand    commandDatabase = new MySqlCommand(query, databaseConnection);
         MySqlDataReader reader          = commandDatabase.ExecuteReader();
         databaseConnection.Close();
     }
 }
        private List <PlayerViewModel> getUpdatedListOfPlayers()
        {
            List <PlayerViewModel> players     = new List <PlayerViewModel>();
            List <PlayerModel>     playersList = PDB.getAllLocalPlayers();

            for (int i = 0; i < playersList.Count; i++)
            {
                EffModel ef = PDB.getPointsAndEff(playersList[i].ID);
                players.Add(new PlayerViewModel(playersList[i].ID, playersList[i].Name, ef.Pts, ef.Eff));
            }
            return(players);
        }
        public EffModel getPointsAndEff(int id)
        {
            EffModel eff = new EffModel();

            databaseConnection.Open();
            query = "SELECT points, eff FROM playerinfo WHERE id = " + id;
            MySqlCommand    commandDatabase = new MySqlCommand(query, databaseConnection);
            MySqlDataReader reader          = commandDatabase.ExecuteReader();

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    eff.Eff = reader.GetDouble(1);
                    eff.Pts = reader.GetDouble(0);
                }
            }
            databaseConnection.Close();
            return(eff);
        }