public async static Task <ObservableCollection <QuestionDAO> > LoadQuestionByGenre(string genre) { ObservableCollection <QuestionDAO> ListQuestion = new ObservableCollection <QuestionDAO>(); try { Dictionary <string, string> myDic = new Dictionary <string, string>(); myDic.Add("genre", genre); var myQues = await App.MobileService.InvokeApiAsync("Question", HttpMethod.Get, myDic); if (myQues != null) { if (ListQuestion.Count != 0) { ListQuestion.Clear(); } ListQuestion.Clear(); foreach (var item in myQues) { ListQuestion.Add(new Models.QuestionDAO(item)); } return(ListQuestion); } ListQuestion.Clear(); return(ListQuestion); } catch (Exception ex) { Debug.WriteLine("! ! ! Loading Question in Service ! ! ! " + ex.Message); return(ConnectServiceHelper.LoadQuestionByGenre(genre).Result); } }
private async void LoadGame() { switch (Global.TypeGenre) { case "default": Global.ListQuestion = await ConnectServiceHelper.LoadListQuestion(); if (Global.ListQuestion != null) { NextQuestion(); } break; case "challenge": Global.ListQuestion = await ConnectServiceHelper.GetListQuestionChallenge(Global.CurrentChallenge.ListIdQuestion); if (Global.ListQuestion != null) { NextQuestion(); } break; default: Global.ListQuestion = await ConnectServiceHelper.LoadQuestionByGenre(Global.TypeGenre); if (Global.ListQuestion != null) { NextQuestion(); } break; } }