예제 #1
0
        /// <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();
        }
예제 #2
0
        /// <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);
        }