public bool AddTeacher(Domain.Teacher newTeacher) { ITeacherDao teacherDao = new TeacherDao(sessionFactory); ISystemUserDao systemUserDao = new SystemUserDao(sessionFactory); //先存入Teacher,在存入SystemUser try { int teacherId= (Int32)teacherDao.Save(newTeacher); SystemUser newSystemUser = new SystemUser { systemUserID =teacherId.ToString(), systemUserPassword = newTeacher.teacherPassword, systemUserType = 2 }; systemUserDao.Save(newSystemUser); return true; }catch(Exception e){ return false; } }
public IList<Teacher> GetAllTeacher() { ITeacherDao teacherDao = new TeacherDao(sessionFactory); try { IList<Teacher> teacherList = teacherDao.LoadAll(); return teacherList; } catch (Exception e) { return null; } }
public Teacher GetTeacherByID(string userID) { int teacherId = Int32.Parse(userID); ITeacherDao teacherDao = new TeacherDao(sessionFactory); return teacherDao.Get(teacherId); }