//退课 public bool DropCourse(int studentId, int courseId) { ICourseDao courseDao = new CourseDao(sessionFactory); Course selectedCourse = courseDao.Get(courseId); ISelectionDao selectionDao = new SelectionDao(sessionFactory); SelectionID selectionID = new SelectionID { selectionStudentID=studentId, selectionCourseID=courseId, selectionStudyYear=selectedCourse.courseStudyYear, selectionTerm=selectedCourse.courseTerm }; Selection selection=selectionDao.Get(selectionID); if (null != selection) { try { selectionDao.Delete(selection); return true; } catch (Exception e) { return false; } } else { return false; } }
public Selection GetSelectionByID(SelectionID selectionId) { ISelectionDao selectionDao = new SelectionDao(sessionFactory); try { return selectionDao.Get(selectionId); } catch (Exception e) { return null; } }
public int GetStudentScore(object selectionID) { ISelectionDao selectionDao= new SelectionDao(sessionFactory); try { Selection selection= selectionDao.Get(selectionID); return selection.selectionScore; } catch (Exception e) { return -1; } }
public void ScoreAStudent() { int score = 60; string studyYear = "2012~2013"; string term = "上"; int courseId =1000; int studentId = 10000002; ISelectionDao selectionDao = new SelectionDao(sessionFactory); SelectionID seletionID = new SelectionID { selectionStudentID=studentId, selectionCourseID= courseId, selectionStudyYear=studyYear, selectionTerm=term }; Selection selectedSelection = selectionDao.Get(seletionID); bool success; if (true == selectedSelection.selectionScorePermit) { selectedSelection.selectionScore = score; success = teacherController.ScoreStudentCourse(selectedSelection); } else { success=false; } Assert.AreEqual(true, success); }