///<summary> ///Check whether student is enrolled ///</summary> ///<param name = "studName">Student's username</param> public async Task <bool> CheckStudEnroll(string studName) { DatabaseQAHandler.GetCourse(courseName, course => { for (int i = 0; i < (course.students).Count; i++) // Loop through List { Debug.Log("STUDENT[I]" + course.students[i]); Debug.Log("studname:" + studName); if (studName == course.students[i]) { Debug.Log("SAMEE"); chk = true; } } }); Stopwatch sw = Stopwatch.StartNew(); var delay = Task.Delay(1000).ContinueWith(_ => { sw.Stop(); return(sw.ElapsedMilliseconds); }); await delay; int sec = (int)delay.Result; Debug.Log("check stud enroll elapsed milliseconds: {0}" + sec + ", Chk is " + chk); return(chk); }
///<summary> ///Check if the course already exist ///</summary> public async Task <bool> CheckCourseExist(string courseName) { chk = false; Debug.Log("line140:" + courseName + "!"); DatabaseQAHandler.GetCourse(courseName, course => { chk = true; Debug.Log("chCourseExist1" + chk); }); Stopwatch sw = Stopwatch.StartNew(); var delay = Task.Delay(2000).ContinueWith(_ => { sw.Stop(); return(sw.ElapsedMilliseconds); }); await delay; int sec = (int)delay.Result; Debug.Log("check course exist elapsed milliseconds: {0}" + sec); locks = false; return(chk); }
///<summary> ///Create rows showing the list of enrolled students ///</summary> public async Task Read() { int count = itemParent.transform.childCount; if (count != null) { for (int i = 0; i < count; i++) { Debug.Log("itemparent"); Destroy(itemParent.transform.GetChild(i).gameObject); } } DatabaseQAHandler.GetCourse(courseName, course => { currentCourse = new Course(userName, course.students); int number = 1; for (int i = 0; i < (course.students).Count; i++) // Loop through List { Debug.Log("STUDENT[I]" + course.students[i]); GameObject tmp_item = Instantiate(item, itemParent.transform); tmp_item.name = i.ToString(); Debug.Log("here item name: " + tmp_item.name); tmp_item.transform.GetChild(0).GetComponent <Text>().text = number.ToString(); tmp_item.transform.GetChild(1).GetComponent <Text>().text = course.students[i]; number++; } }); Stopwatch sw = Stopwatch.StartNew(); var delay = Task.Delay(1000).ContinueWith(_ => { sw.Stop(); return(sw.ElapsedMilliseconds); }); await delay; int sec = (int)delay.Result; Debug.Log("Read elapsed milliseconds: {0}" + sec); }