public IActionResult Start(StartQuiz model) { if (ModelState.IsValid) { HttpContext.Session.SetString("Name", model.Name); HttpContext.Session.SetString("Topic", model.Topic); } var quizManager = new QuizManager(true); var isCreated = quizManager.IntializeRandomQuestions(10, model.Topic); if (isCreated) { var question = quizManager.GetQuestion(); UpdateSession(quizManager); return(View("Quiz", question)); } else { return(View("Error", new ErrorViewModel() { ErrorMessage = "The total questions available in the specified topic are less than the required questions for the quiz" })); } }
private void Btn_Click(object sender, EventArgs e) { StartQuiz startQuiz = new StartQuiz($@"C:\Users\{Environment.UserName}\Documents\Quiz App\{(sender as Button).Tag?.ToString()}"); Visible = false; startQuiz.Show(); }
private void Button_Click(object sender, RoutedEventArgs e) { Button button = sender as Button; var context = button.DataContext as Category; UserControl usc = new StartQuiz(context.ID, context.CategoryName); GridMain.Children.Add(usc); }