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(); } } }
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(); } } }