Beispiel #1
0
        public Player PlayerLogin(string email)
        {
            MySqlCommand    cmd = new MySqlCommand("proc_player_login", conn);
            MySqlDataReader reader;

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add(new MySqlParameter("p_email", email));

            Player player = null;

            try
            {
                conn.Open();
                reader = cmd.ExecuteReader();

                if (reader.Read())
                {
                    player = new Player();

                    player.Id       = (int)reader.GetValue(0);
                    player.Password = reader.GetValue(1).ToString();
                }
            }
            catch (Exception e)
            {
                conn.Close();
                LogError.GenerateError("PlayerDAL", "PlayerLogin", e.InnerException.ToString());
            }
            finally
            {
                conn.Close();
            }

            return(player);
        }
Beispiel #2
0
        public List <Player> PlayerAvailabeSelect()
        {
            MySqlCommand    cmd = new MySqlCommand("proc_player_list", conn);
            MySqlDataReader reader;

            cmd.CommandType = CommandType.StoredProcedure;

            List <Player> players = new List <Player>();
            Player        player  = new Player();

            try
            {
                conn.Open();
                reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    player.Id       = (int)reader.GetValue(0);
                    player.Name     = reader.GetValue(1).ToString();
                    player.Birthday = DateTime.Parse(reader.GetValue(2).ToString());
                    player.Nick     = reader.GetValue(4).ToString();
                    player.Email    = reader.GetValue(6).ToString();
                    player.Skype    = reader.GetValue(7).ToString();
                    player.Champion = (Champions)Enum.Parse(typeof(Champions), reader.GetValue(8).ToString(), true);
                    player.Role1    = (Roles)Enum.Parse(typeof(Roles), reader.GetValue(9).ToString(), true);
                    player.Role2    = (Roles)Enum.Parse(typeof(Roles), reader.GetValue(10).ToString(), true);
                    player.IdRiot   = long.Parse(reader.GetValue(14).ToString());
                    player.State    = (States)Enum.Parse(typeof(States), reader.GetValue(17).ToString(), true);
                    player.Schedule = (Schedule)Enum.Parse(typeof(Schedule), reader.GetValue(18).ToString(), true);
                    player.Schedule = (Schedule)Enum.Parse(typeof(Schedule), reader.GetValue(20).ToString(), true);

                    players.Add(player);
                    player = new Player();
                }
            }
            catch (Exception e)
            {
                LogError.GenerateError("PlayerDAL", "PlayerAvailabeSelect", e.InnerException.ToString());
                conn.Close();
            }
            finally
            {
                conn.Close();
            }

            return(players);
        }