Example #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)
        {
            // Does not need to check UpperLimit since HonoursState is the highest GradePointState possible.

            // Go to lower neighboring sibling: REGULARSTATE
            if (student.GradePointAverage < this.LowerLimit)
            {
                student.GradePointStateId = RegularState.GetInstance().GradePointStateId;
            }

            db.SaveChanges();
        }
Example #2
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: REGULARSTATE
            if (student.GradePointAverage > this.UpperLimit)
            {
                student.GradePointStateId = RegularState.GetInstance().GradePointStateId;
            }

            // Go to lower neighboring sibling: SUSPENDEDSTATE
            if (student.GradePointAverage < this.LowerLimit)
            {
                student.GradePointStateId = SuspendedState.GetInstance().GradePointStateId;
            }

            db.SaveChanges();
        }
Example #3
0
        /// <summary>
        /// Checks for an existing RegularState instance.
        /// Instantiates an RegularState and populates it to the database if there is none.
        /// </summary>
        /// <returns>honourState : instance of the RegularState sub class</returns>
        public static RegularState GetInstance()
        {
            if (regularState == null)
            {
                BITCollege_MGContext db = new BITCollege_MGContext();
                regularState = db.RegularStates.SingleOrDefault();

                if (regularState == null)
                {
                    RegularState regularState = new RegularState();

                    db.RegularStates.Add(regularState);
                    db.SaveChanges();
                }
            }

            return(regularState);
        }