public async Task <bool> UpdateCharacter(int index, PonyData pony) { if (m_data == null || index >= m_data.Count) { return(false); } CharsMgr.ValidatePonyData(pony); if (index == -1) { if (m_data.Count >= CharsMgr.MaxChars) { return(false); } var character = await ServerDB.CreateCharacterAsync(_user.ID, pony); if (character == null) { return(false); } m_data.Add(character); } else { var character = m_data[index]; character.Pony = pony; if (!await ServerDB.UpdatePonyAsync(character)) { return(false); } } return(true); }
private async void Player_NetUserDataChanged(Player obj) { if (m_data != null) { return; } m_data = await ServerDB.SelectAllUserCharactersAsync(_user.ID); if (m_data != null) { foreach (var item in m_data) { CharsMgr.ValidatePonyData(item.Pony); } this.SendPonies(); } else { _player.Error($"Error while retrieving ponies from data base"); } }