public QuizController() { this.Client.BaseAddress = new Uri("http://localhost:9080/PIDEV-web/"); this.Client.DefaultRequestHeaders.Accept. Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); QsVm = new QuizSelectionVM(); QpVm = new QuizSessionVM(); }
public ActionResult Index() { QsVm = new QuizSelectionVM(); HttpClient Client = new HttpClient(); HttpResponseMessage response; Client.BaseAddress = new Uri("http://localhost:9080/PIDEV-web/"); Client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); response = Client.GetAsync("PIDEV/gestionQuiz/category").Result; Console.WriteLine(response); var jsonString = response.Content.ReadAsStringAsync(); jsonString.Wait(); List <Data.category> cats = new List <Data.category>() { new Data.category() { name = "MyCat" } }; var x = jsonString.Result; cats = JsonConvert.DeserializeObject <List <Data.category> >(jsonString.Result); ViewBag.cats = new SelectList(cats, "id", "name");; // Prepare dropdown for categories... IEnumerable <SelectListItem> items = cats.Select(c => new SelectListItem { Value = c.id.ToString(), Text = c.name }); QsVm.dropDownCategories = items; if (ModelState.IsValid) { Console.WriteLine("SELECTED CATEGORY: " + QsVm.SelectedCategory); //check for model.SelectedCountry property value here //Save and Redirect } return(View()); }
public ActionResult QuizSelection(QuizSelectionVM InQsVm) { Console.WriteLine(InQsVm); return(RedirectToAction("LoadQuizSession", "QuizSession", new { skillId = InQsVm.SelectedSkill })); }