///<summary> ///Delete course in database ///</summary> public async void DeleteCourse() { loader.SetActive(true); Debug.Log("DELETE name: " + courseKey); DatabaseQAHandler.DeleteCourse(courseKey, () => { }); DatabaseQAHandler.GetCourseLvlQns(courseLvlQns => { foreach (var courseLvlQn in courseLvlQns) { //Debug.Log($"{course.Key} {course.Value.userName}"); if (courseLvlQn.Value.courseName == courseKey) //Find course created by you { DatabaseQAHandler.DeleteCourseLvlQn(courseLvlQn.Key, () => { }); } } }); Stopwatch sw = Stopwatch.StartNew(); var delay = Task.Delay(1000).ContinueWith(_ => { sw.Stop(); return(sw.ElapsedMilliseconds); }); await delay; int sec = (int)delay.Result; Debug.Log("Delete elapsed milliseconds: {0}" + sec); await Read(); loader.SetActive(false); messageBox.SetActive(true); messageBox.transform.GetChild(1).GetComponent <Text>().text = courseKey + " deleted successfully."; courseKey = null; }
///<summary> ///Delete course in database ///</summary> public async void DeleteCourseLvl() { loader.SetActive(true); Debug.Log("DELETE name: " + key); DatabaseQAHandler.DeleteCourseLvlQn(key, () => { }); Stopwatch sw = Stopwatch.StartNew(); var delay = Task.Delay(1000).ContinueWith(_ => { sw.Stop(); return(sw.ElapsedMilliseconds); }); await delay; int sec = (int)delay.Result; Debug.Log("Delete elapsed milliseconds: {0}" + sec); await Read(); loader.SetActive(false); messageBox.SetActive(true); messageBox.transform.GetChild(1).GetComponent <Text>().text = "Deleted successfully."; key = null; }