public IActionResult PlayQuiz() { var model = new SelectCategoryViewModel { }; if (_quiz_CategoryRepository.GetAllCategory() == null) { ViewBag.ErrorMessage = $" is not found"; return(View("NotFound")); } foreach (var category in _quiz_CategoryRepository.GetAllCategory()) { model.categories.Add(category.qc_type); } return(View(model)); }
public async Task <IActionResult> EditSubCategories() { var userId = User.FindFirstValue(ClaimTypes.NameIdentifier); var specialist = await _specialistService.FindAsync(userId, true); var selectedSubCategories = specialist.SpecialistSubCategories.Select(m => m.SubCategory); var allCategories = await _categoryService.GetAllCategories(true); var selectCategoriesViewModel = new List <SelectCategoryViewModel>(); foreach (var category in allCategories) { var selectCategoryViewModel = new SelectCategoryViewModel(); selectCategoryViewModel.Category = category; selectCategoryViewModel.SelectSubCategory = category.SubCategories.Select(m => new SelectSubCategoryViewModel() { Selected = selectedSubCategories.Contains(m), SubCategory = m }).ToList(); selectCategoriesViewModel.Add(selectCategoryViewModel); } return(View(selectCategoriesViewModel)); }
//[HttpGet] public async Task <IActionResult> ShowQuestion(SelectCategoryViewModel model) { /* * if (type == null) * { * ViewBag.ErrorMessage = "type is empty"; * return View("NotFound"); * } * else * { * ViewBag.msg = type; * } */ string type = null; type = model.qc_Type; List <Quiz_question> qq_list = new List <Quiz_question>(); int id1 = 0; Quiz_question[] qqobj = new Quiz_question[5]; try { var id = from x in _context.quiz_Categories where x.qc_type == type select x.qc_Id; id1 = id.FirstOrDefault(); } catch (Exception e) { } var quiz_questions = from x in _context.quiz_Questions where x.qc_Id == id1 select x; ViewBag.linqinstance = quiz_questions; return(View()); }