Example #1
0
 public bool PasswordIsOkay(string username, string password)
 {
     lock (_accountsExpectant)
     {
         using (AccountsContext db = new AccountsContext())
         {
             var _accounts = db.Accounts;
             foreach (Account a in _accounts)
             {
                 if (a.Login.Equals(username))
                 {
                     if (a.Password.Equals(password))
                     {
                         return(true);
                     }
                     else
                     {
                         return(false);
                     }
                 }
             }
         }
         return(false);
     }
 }
Example #2
0
        public void SaveAccount(Account account)
        {
            lock (_accountsExpectant)
            {
                using (AccountsContext db = new AccountsContext())
                {
                    db.Entry(account).State = EntityState.Modified;

                    db.Entry(account.AccountParameters).State = EntityState.Modified;

                    db.Entry(account.AccountSkillBuilds).State = EntityState.Modified;

                    db.SaveChanges();
                }
            }
        }
Example #3
0
 public void AddAccount(string username, string password, string nickname)
 {
     lock (_accountsExpectant)
     {
         using (AccountsContext db = new AccountsContext())
         {
             Account _newAccount = new Account()
             {
                 Login = username, Password = password, Nickname = nickname, GuideKey = GetGuideKey(5), Friends = new string[0]
             };
             db.Accounts.Add(_newAccount);
             db.SaveChanges();
             AccountParameters _newAccountParameters = new AccountParameters()
             {
                 Id     = _newAccount.Id,
                 Levels = new int[] { 0, 0, 0, 0, 0 },
                 Ranks  = new int[] { 0, 0, 0, 0, 0 }
             };
             db.AccountsParameters.Add(_newAccountParameters);
             db.SaveChanges();
             AccountSkillBuilds _newAccountSkillBuilds = new AccountSkillBuilds()
             {
                 Id         = _newAccount.Id,
                 IgnisBuild = new short[9] {
                     0, 0, 0, 0, 0, 0, 0, 0, 0
                 },
                 TerraBuild = new short[9] {
                     0, 0, 0, 0, 0, 0, 0, 0, 0
                 },
                 AquaBuild = new short[9] {
                     0, 0, 0, 0, 0, 0, 0, 0, 0
                 },
                 CaeliBuild = new short[9] {
                     0, 0, 0, 0, 0, 0, 0, 0, 0
                 },
                 PrimusBuild = new short[9] {
                     0, 0, 0, 0, 0, 0, 0, 0, 0
                 }
             };
             _newAccount = db.Accounts.Find(_newAccount.Id);
             _newAccount.AccountParameters  = _newAccountParameters;
             _newAccount.AccountSkillBuilds = _newAccountSkillBuilds;
             db.SaveChanges();
         }
     }
 }
Example #4
0
 public Account GetAccount(string username)
 {
     lock (_accountsExpectant)
     {
         using (AccountsContext db = new AccountsContext())
         {
             var _accounts = db.Accounts;
             foreach (Account a in _accounts.Include(a => a.AccountParameters).Include(b => b.AccountSkillBuilds))
             {
                 if (a.Login.Equals(username))
                 {
                     return(a);
                 }
             }
         }
         return(null);
     }
 }
Example #5
0
 public bool NicknameExist(string nickname)
 {
     lock (_accountsExpectant)
     {
         using (AccountsContext db = new AccountsContext())
         {
             var _accounts = db.Accounts;
             foreach (Account a in _accounts)
             {
                 if (a.Nickname.Equals(nickname))
                 {
                     return(true);
                 }
             }
         }
         return(false);
     }
 }
Example #6
0
 public bool LoginExist(string username)
 {
     lock (_accountsExpectant)
     {
         using (AccountsContext db = new AccountsContext())
         {
             var _accounts = db.Accounts;
             foreach (Account a in _accounts)
             {
                 if (a.Login.Equals(username))
                 {
                     return(true);
                 }
             }
         }
         return(false);
     }
 }