//----------------------------------------------------------------------------------------------------------------------------------------------// public void Create() { creating = true; string groupName = groupManager.activeGroup.groupName; string projectRefName = "(" + groupName + ") " + projectName.text; DataRef.Groups(groupName).GetValueAsync().ContinueWith(async(task) => { await new WaitForUpdate(); DataSnapshot snapshot = task.Result; SetReference(groupName, "Project" + (snapshot.Child("Projects").ChildrenCount + 1).ToString(), projectRefName); }); DataRef.Projects(projectRefName).Child("ProjectName").SetValueAsync(projectName.text).ContinueWith(async(task) => { await new WaitForUpdate(); }); DataRef.Projects(projectRefName).Child("ProjectDescription").SetValueAsync(projectDescription.text).ContinueWith(async(task) => { await new WaitForUpdate(); }); DataRef.Projects(projectRefName).Child("FundingGoal").SetValueAsync((int.Parse(fund) * 100).ToString()).ContinueWith(async(task) => { await new WaitForUpdate(); }); DataRef.Projects(projectRefName).Child("FundingAmount").SetValueAsync("0").ContinueWith(async(task) => { await new WaitForUpdate(); }); DataRef.Projects(projectRefName).Child("Group").SetValueAsync(groupName).ContinueWith(async(task) => { await new WaitForUpdate(); }); foreach (string tag in categoryTags) { DataRef.Projects(projectRefName).Child("Tags").Child("Categories").Child(tag).SetValueAsync(tag).ContinueWith(async(task) => { await new WaitForUpdate(); }); DataRef.Filters("Category").Child(tag).Child(projectRefName).SetValueAsync(projectRefName).ContinueWith(async(task) => { await new WaitForUpdate(); }); } DataRef.Filters("Location").Child(locationText.text).Child(projectRefName).SetValueAsync(projectRefName).ContinueWith(async(task) => { await new WaitForUpdate(); }); DataRef.Projects(projectRefName).Child("Tags").Child("Location").SetValueAsync(locationText.text).ContinueWith(async(task) => { await new WaitForUpdate(); ResetFields(); canvasScript.ToggleDoerSub(false); creating = false; groupManager.activeGroup.Populate(); }); activityManager.SetAlertNewProject(projectRefName, "Group_Default"); //activityManager.Resubscribe (); }
//----------------------------------------------------------------------------------------------------------------------------------------------// public void Search() { ClearList(); locationProjects.Clear(); categoryProjects.Clear(); mergedProjectsList.Clear(); List <string> categoriesList = new List <string> (); for (int i = 0; i < category.childCount - 1; i++) { if (category.GetChild(i).GetComponent <FilterButton> ().selected) { categoriesList.Add(category.GetChild(i).GetChild(1).GetComponent <Text> ().text); } } categoriesList = categoriesList.Distinct().ToList(); DataRef.Filters("Category").GetValueAsync().ContinueWith(async(task) => { await new WaitForUpdate(); DataSnapshot snapshot = task.Result; foreach (string category in categoriesList) { foreach (DataSnapshot snap in snapshot.Child(category).Children) { if (!categoryProjects.Contains(snap.Value.ToString())) { categoryProjects.Add(snap.Value.ToString()); } } } }); List <string> locationsList = new List <string> (); for (int i = 0; i < location.childCount - 1; i++) { if (location.GetChild(i).GetComponent <FilterButton> ().selected) { locationsList.Add(location.GetChild(i).GetChild(1).GetComponent <Text> ().text); } } locationsList = locationsList.Distinct().ToList(); DataRef.Filters("Location").GetValueAsync().ContinueWith(async(task) => { await new WaitForUpdate(); DataSnapshot snapshot = task.Result; foreach (string location in locationsList) { foreach (DataSnapshot snap in snapshot.Child(location).Children) { if (!locationProjects.Contains(snap.Value.ToString())) { locationProjects.Add(snap.Value.ToString()); } } } foreach (string project in categoryProjects) { if (locationProjects.Contains(project)) { mergedProjectsList.Add(project); } } for (int i = 0; i < mergedProjectsList.Count; i++) { InstantiateProject(mergedProjectsList[i]); } }); }