Esempio n. 1
0
        public static List <ExamResult> GetResultsByExam(DBConnection connection, int examId)
        {
            SqlCommand command = connection.GetCommand(ExamResultTable.SQL_SELECT_EXAMRESULTS_BY_EXAM);

            command.AddParameter("@examId", SqlDbType.Int, examId);

            using (SqlDataReader reader = command.ExecuteReader())
            {
                List <ExamResult> results = new List <ExamResult>();

                while (reader.Read())
                {
                    results.Add(ExamResultTable.ReadExamResult(reader));
                }

                return(results);
            }
        }
Esempio n. 2
0
        public static ExamResult GetExamResultById(DBConnection connection, int examResultId)
        {
            SqlCommand command = connection.GetCommand(ExamResultTable.SQL_SELECT_EXAMRESULT_BY_ID);

            command.AddParameter("@examResultId", SqlDbType.Int, examResultId);

            using (SqlDataReader reader = command.ExecuteReader(CommandBehavior.SingleRow))
            {
                if (reader.HasRows)
                {
                    reader.Read();

                    return(ExamResultTable.ReadExamResult(reader, examResultId));
                }
                else
                {
                    throw new DatabaseException("Tento výsledek testu nebyl nalezen");
                }
            }
        }
Esempio n. 3
0
 private static ExamResult ReadExamResult(SqlDataReader reader)
 {
     return(ExamResultTable.ReadExamResult(reader, (int)reader.GetColumnValue <decimal>("examResultId")));
 }