/// <summary> /// Changes Student GradePointState from one state to another depending on the GradePointAverage. /// </summary> /// <param name="student">Student object</param> public override void StateChangeCheck(Student student) { // Go to higher neighboring sibling: HONOURSSTATE if (student.GradePointAverage > this.UpperLimit) { student.GradePointStateId = HonoursState.GetInstance().GradePointStateId; } // Go to lower neighboring sibling: PROBATIONSTATE if (student.GradePointAverage < this.LowerLimit) { student.GradePointStateId = ProbationState.GetInstance().GradePointStateId; } db.SaveChanges(); }
/// <summary> /// Checks for an existing HonoursState instance. /// Instantiates an HonoursState and populates it to the database if there is none. /// </summary> /// <returns>honourState : instance of the HonoursState sub class</returns> public static HonoursState GetInstance() { if (honoursState == null) { BITCollege_MGContext db = new BITCollege_MGContext(); honoursState = db.HonoursStates.SingleOrDefault(); if (honoursState == null) { HonoursState honoursState = new HonoursState(); db.HonoursStates.Add(honoursState); db.SaveChanges(); } } return(honoursState); }