/// <summary> /// Return één enkele Teacher. /// </summary> public Models.BU.Teacher GetSingleTeacher(string query) { Connect(); try { SqlCommand cmd = new SqlCommand(query, conn); conn.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Models.BU.Teacher singleTeacher = new Models.BU.Teacher(Convert.ToInt32(reader["UserId"]), reader["Username"].ToString(), reader["EmailAdress"].ToString(), reader["Firstname"].ToString(), reader["Lastname"].ToString()); Debug.WriteLine("GetSingleTeacher - Succes."); return(singleTeacher); } } catch (Exception) { Debug.WriteLine("GetSingleTeacher - Exception!"); return(null); } Debug.WriteLine("GetSingleTeacher - Niks gevonden."); return(null); }
/// <summary> /// Return een lijst van Lectures op basis van userId /// </summary> public List <Models.BU.Lecture> GetLecturesOfTeacher(string query, int userId) { Connect(); try { SqlCommand cmd = new SqlCommand(query, conn); conn.Open(); SqlDataReader reader = cmd.ExecuteReader(); List <Models.BU.Lecture> lectureList = new List <Models.BU.Lecture>(); Models.BU.Teacher tempTeacher = GetSingleTeacher("SELECT * from UserAccount WHERE UserId = '" + userId + "'"); while (reader.Read()) { Models.BU.Lecture tempLecture = new Models.BU.Lecture(tempTeacher, GetSingleModule("SELECT * FROM Module WHERE Code = '" + reader["ModuleCode"].ToString() + "'"), reader["Classroom"].ToString(), reader["StudentGroup"].ToString(), Convert.ToInt32(reader["Period"]), Convert.ToInt32(reader["Week"]), Convert.ToInt32(reader["Day"]), Convert.ToInt32(reader["StartHour"]), Convert.ToInt32(reader["StartMinute"]), Convert.ToInt32(reader["EndHour"]), Convert.ToInt32(reader["EndMinute"])); lectureList.Add(tempLecture); } Debug.WriteLine("GetLecturesOfTeacher - Succes."); return(lectureList); } catch (Exception) { Debug.WriteLine("GetLecturesOfTeacher - Exception!"); return(null); } }
/// <summary> /// Return een lijst van Teachers /// </summary> public List <Models.BU.Teacher> GetTeacherList(string query) { Connect(); try { SqlCommand cmd = new SqlCommand(query, conn); conn.Open(); SqlDataReader reader = cmd.ExecuteReader(); List <Models.BU.Teacher> teacherList = new List <Models.BU.Teacher>(); while (reader.Read()) { Models.BU.Teacher tempTeacher = new Models.BU.Teacher(Convert.ToInt32(reader["UserId"]), reader["Username"].ToString(), reader["EmailAdress"].ToString(), reader["Firstname"].ToString(), reader["Lastname"].ToString()); teacherList.Add(tempTeacher); } Debug.WriteLine("GetTeacherList - Succes."); return(teacherList); } catch (Exception) { Debug.WriteLine("GetTeacherList - Exception!"); return(null); } }