///<summary> ///Creating question in Database ///</summary> ///<param name = "qn">Question Input</param> ///<param name = "ans">Answer Input</param> public async Task PostingQn(string qn, string ans) { int intAns = int.Parse(ans, System.Globalization.NumberStyles.Integer); (courseLvlQnCreate.qns).Add(qn); (courseLvlQnCreate.ans).Add(intAns); DatabaseQAHandler.PutCourseLvlQn(key, courseLvlQnCreate, () => { }); Stopwatch sw = Stopwatch.StartNew(); var delay = Task.Delay(1000).ContinueWith(_ => { sw.Stop(); return(sw.ElapsedMilliseconds); }); await delay; int sec = (int)delay.Result; Debug.Log("Creating Qn Elapsed milliseconds: {0}" + sec); }
///<summary> ///Update question in Database ///</summary> ///<param name = "qn">Question Input</param> ///<param name = "ans">Answer Input</param> public async Task UpdateQn(string qn, string ans) { loader.SetActive(true); courseLvlQnCreate.qns[editName] = qn; courseLvlQnCreate.ans[editName] = int.Parse(ans, System.Globalization.NumberStyles.Integer); DatabaseQAHandler.PutCourseLvlQn(key, courseLvlQnCreate, () => { }); Stopwatch sw = Stopwatch.StartNew(); var delay = Task.Delay(1000).ContinueWith(_ => { sw.Stop(); return(sw.ElapsedMilliseconds); }); await delay; int sec = (int)delay.Result; Debug.Log("Updating Qn Elapsed milliseconds: {0}" + sec); await Read(); loader.SetActive(false); messageBox.SetActive(true); messageBox.transform.GetChild(1).GetComponent <Text>().text = "Updated successfully."; }
///<summary> ///Deleting question in Database ///</summary> public async void DeleteQn() { loader.SetActive(true); (courseLvlQnCreate.qns).RemoveAt(delName); (courseLvlQnCreate.ans).RemoveAt(delName); DatabaseQAHandler.PutCourseLvlQn(key, courseLvlQnCreate, () => { }); Stopwatch sw = Stopwatch.StartNew(); var delay = Task.Delay(1000).ContinueWith(_ => { sw.Stop(); return(sw.ElapsedMilliseconds); }); await delay; int sec = (int)delay.Result; Debug.Log("Creating Qn Elapsed milliseconds: {0}" + sec); await Read(); loader.SetActive(false); messageBox.SetActive(true); messageBox.transform.GetChild(1).GetComponent <Text>().text = "Deleted successfully."; //key = null; }