private void ChatCharacters_ChildAdded(object sender, ChildChangedEventArgs e) { var parent = e.Snapshot.Key; if (!_chatCharacterDataDict.ContainsKey(parent)) { _chatCharacterDataDict.Add(parent, new List <ChatCharacterData>()); } var data = JSONSerialization <ChatCharacterData> .CreateDictionaryFromJSON(e.Snapshot.GetRawJsonValue()); foreach (var character in data) { character.Value.Key = character.Key; _chatCharacterDataDict[parent].Add(character.Value); } foreach (var character in _chatCharacterDataDict[parent]) { _databaseRef.Child(DB_NODE_CHARACTERS).Child(character.CharacterId).GetValueAsync().ContinueWith(innerTask => { character.Data = JSONSerialization <CharacterData> .CreateFromJSON(innerTask.Result.GetRawJsonValue()); }); } }
private void createNewUserData(IGraphResult result) { Client.UserData = new User(); var userData = JSONSerialization <User> .CreateFromJSON(result.RawResult); Client.UserData = userData; Client.UserData.Token = AccessToken.CurrentAccessToken.TokenString; Client.UserData.ChatCount = 0; Client.UserData.ActiveChats = new Dictionary <string, string>(); Client.UserData.Invites = new Dictionary <string, string>(); DatabaseService.Instance.CreateUserDataEvent += handleCreateUserDataEvent; DatabaseService.Instance.CreateNewUser(Client.UserData); }
public void GetUserInviteChats(string userId) { _databaseRef.Child(DB_NODE_USERS).Child(userId).Child("InviteChats").GetValueAsync().ContinueWith(task => { if (task.IsCompleted) { var data = JSONSerialization <Dictionary <string, string> > .CreateFromJSON(task.Result.GetRawJsonValue()); if (GetInviteChatEvent != null) { GetInviteChatEvent.Invoke(true, data); } } else if (task.IsFaulted) { } }); }
public void GetUserDataById(string id) { _databaseRef.Child(DB_NODE_USERS).Child(id).GetValueAsync().ContinueWith(task => { User userdata = null; if (task.IsCompleted) { if (task.Result.Exists) { userdata = JSONSerialization <User> .CreateFromJSON(task.Result.GetRawJsonValue()); } } else if (task.IsFaulted) { } if (GetUserDataEvent != null) { GetUserDataEvent.Invoke(task.IsCompleted, userdata); } }); }