Beispiel #1
1
        public static Models.AccountsModel LoadAccount(int accountID)
        {
            DatabaseProvider.CheckConnection();

            lock (DatabaseProvider.ConnectionLocker)
            {
                var account = new Models.AccountsModel();

                var sqlText = "SELECT * FROM dyn_accounts WHERE id=@id";
                var sqlCommand = new MySqlCommand(sqlText, DatabaseProvider.Connection);
                sqlCommand.Parameters.Add(new MySqlParameter("@id", accountID));

                var sqlReader = sqlCommand.ExecuteReader();

                if (sqlReader.Read())
                {
                    account.ID = sqlReader.GetInt16("id");
                    account.Username = sqlReader.GetString("username");
                    account.Password = sqlReader.GetString("password");
                    account.Pseudo = sqlReader.GetString("pseudo");
                    account.Communauty = sqlReader.GetInt16("communauty");
                    account.Level = sqlReader.GetInt16("gmLevel");
                    account.Question = sqlReader.GetString("question");
                    account.Answer = sqlReader.GetString("answer");
                    account.SubscriptionDate = sqlReader.GetDateTime("subscription");
                }

                sqlReader.Close();

                return account;
            }
        }
        private Entities.Accounts ModelToEntityMapper(Models.AccountsModel Account)
        {
            Entities.Accounts AccountEntity = new Entities.Accounts
            {
                AccountID = Account.AccountID,
                Name      = Account.Name,
                ManagerID = Account.ManagerID
            };

            return(AccountEntity);
        }
Beispiel #3
0
        public static Models.AccountsModel LoadAccount(string username)
        {
            Models.AccountsModel account = null;

            DatabaseProvider.CheckConnection();

            lock (DatabaseProvider.Locker)
            {

                var sqlText = "SELECT * FROM accounts WHERE username=@username";
                var sqlCommand = new MySqlCommand(sqlText, DatabaseProvider.Connection);

                sqlCommand.Parameters.Add(new MySqlParameter("@username", username));

                var sqlReader = sqlCommand.ExecuteReader();

                if (sqlReader.Read())
                {
                    account = new Models.AccountsModel()
                    {
                        ID = sqlReader.GetInt16("id"),
                        Username = sqlReader.GetString("username"),
                        Password = sqlReader.GetString("password"),
                        Pseudo = sqlReader.GetString("pseudo"),
                        Communauty = sqlReader.GetInt16("communauty"),
                        Level = sqlReader.GetInt16("gmLevel"),
                        Question = sqlReader.GetString("question"),
                        Answer = sqlReader.GetString("answer"),
                        SubscriptionDate = sqlReader.GetDateTime("subscription"),
                    };
                }

                sqlReader.Close();

                if (account != null)
                {
                    account.Characters = LoadCharacters(account.ID);
                    account.Friends = LoadFriends(account.ID);
                    account.Enemies = LoadEnemies(account.ID);
                }
            }

            return account;
        }