Exemple #1
0
 public static string ToJsonString(ClassesTaughtModel model)
 {
     if (model != null)
     {
         return(JsonConvert.SerializeObject(model));
     }
     else
     {
         return(null);
     }
 }
Exemple #2
0
        //classes taught list
        public static ClassesTaughtModel GetClassesTaught(int instructorID, int year)
        {
            ClassesTaughtModel classesTaught = null;
            SqlConnection      connection    = GetConnection();

            string selectStatement = "EXEC ClassesTaught @instructorID, @year";

            SqlCommand command = new SqlCommand(selectStatement, connection);

            command.Parameters.AddWithValue("instructorID", instructorID);
            command.Parameters.AddWithValue("year", year);

            try
            {
                connection.Open();
                SqlDataReader reader = command.ExecuteReader();
                classesTaught = new ClassesTaughtModel();
                while (reader.Read())
                {
                    ClassesTaughtModel.Data data = new ClassesTaughtModel.Data();
                    data.bannercrn = Convert.ToInt32(reader["bannerCRN"].ToString());
                    data.semester  = Convert.ToInt32(reader["Semester"].ToString());
                    data.year      = Convert.ToInt32(reader["Year"].ToString());
                    data.subcode   = reader["SubjectCode"].ToString();
                    data.coursenum = Convert.ToInt32(reader["CourseNumber"].ToString());
                    data.score     = Convert.ToDouble(reader["score"].ToString());
                    data.responses = Convert.ToInt32(reader["responses"].ToString());
                    data.students  = Convert.ToInt32(reader["students"].ToString());
                    data.stddev    = Convert.ToDouble(reader["standardDeviation"].ToString());
                    data.testname  = reader["testName"].ToString();

                    classesTaught.DATA.Add(data);
                }

                return(classesTaught);
            }

            catch (SqlException ex)
            {
                return(null);
            }


            finally
            {
                connection.Close();
            }
        }