public void LoadQuestionario() { FirebaseDatabase.DefaultInstance.GetReference("Questionarios").Child(nomeSala.text) /*.Child("info").*/.OrderByChild("nomeQuestionario").EqualTo(nomeSala.text).GetValueAsync() .ContinueWith((task => { if (task.IsFaulted) { print("faulted"); return; } if (task.IsCanceled) { print("canceled"); return; } if (task.IsCompleted) { DataSnapshot snapshot = task.Result; InfoQuestionario extractedData = JsonUtility.FromJson <InfoQuestionario>(snapshot.GetRawJsonValue()); n = extractedData.n; print(n); print(extractedData.uidAutor); //foreach (var child in snapshot.Children) //{ // string t = child.GetRawJsonValue(); // User extractedData = JsonUtility.FromJson<User>(t); //} } } )); fases = new Fase[n]; for (int i = 0; i < n; i++) { FirebaseDatabase.DefaultInstance.GetReference("Questionarios").Child(nomeSala.text).Child("fase" + i).GetValueAsync() .ContinueWith((task => { if (task.IsFaulted) { print("faulted"); return; } if (task.IsCanceled) { print("canceled"); return; } if (task.IsCompleted) { DataSnapshot snapshot = task.Result; Fase extractedData = JsonUtility.FromJson <Fase>(snapshot.GetRawJsonValue()); print(extractedData.vCorreta); } } )); } }
public void SaveQuestionario() { for (int i = 0; i < fases.Length; i++) { string jsonData = JsonUtility.ToJson(fases[i]); print(jsonData); databaseReference.Child("Questionarios").Child(nomeQuestionario.text).Child("fase" + i).SetRawJsonValueAsync(jsonData); } InfoQuestionario iq = new InfoQuestionario(FirebaseAuth.DefaultInstance.CurrentUser.UserId, nomeQuestionario.text, int.Parse(numeroQuestoes.text)); string jsonDataIq = JsonUtility.ToJson(iq); databaseReference.Child("Questionarios").Child(nomeQuestionario.text).Child("info").SetRawJsonValueAsync(jsonDataIq); print(iq); }