public TestQuestionListModel GetAllQuestionsForSubject(int SubId)
        {
            string connectionString     = "server=localhost;uid=root;password=Reset1234;database=OnlineTestManagement;";
            TestQuestionListModel model = new TestQuestionListModel();

            model.QuestionList = new List <Question>();
            string queryString =
                "SELECT Id, Question FROM OnlineTestManagement.Test where SubjectId=" + SubId + ";";

            using (MySqlConnection connection =
                       new MySqlConnection(connectionString))
            {
                MySqlCommand command =
                    new MySqlCommand(queryString, connection);
                connection.Open();

                MySqlDataReader reader = command.ExecuteReader();

                // Call Read before accessing data.
                while (reader.Read())
                {
                    Question obj = new Question();
                    obj.Id   = (int)reader[0];
                    obj.Text = reader[1].ToString();
                    model.QuestionList.Add(obj);
                }

                // Call Close when done reading.
                connection.Close();
            }

            return(model);
        }
Exemple #2
0
        public IViewComponentResult InvokeAsync(int SubId, bool IsPartial)
        {
            TestQuestionListModel ResponseModel = _testService.GetAllQuestionsForSubject(SubId);

            ViewBag.ShowEmptyState = !IsPartial;
            return(View(ResponseModel));
        }
Exemple #3
0
        public TestQuestionListModel GetAllQuestionsForSubject(int SubId)
        {
            TestQuestionListModel model = _testRepository.GetAllQuestionsForSubject(SubId);

            return(model);
        }