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)
        {
            // Go to higher neighboring sibling: PROBATIONSTATE
            if (student.GradePointAverage > this.UpperLimit)
            {
                student.GradePointStateId = ProbationState.GetInstance().GradePointStateId;

                db.SaveChanges();
            }

            // Does not need to check lower limit since SuspendedState is the lowest state possible.
        }
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: 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();
        }
Example #3
0
        /// <summary>
        /// Checks for an existing ProbationState instance.
        /// Instantiates an ProbationState and populates it to the database if there is none.
        /// </summary>
        /// <returns>honourState : instance of the ProbationState sub class</returns>
        public static ProbationState GetInstance()
        {
            if (probationState == null)
            {
                BITCollege_MGContext db = new BITCollege_MGContext();
                probationState = db.ProbationStates.SingleOrDefault();

                if (probationState == null)
                {
                    ProbationState probationState = new ProbationState();

                    db.ProbationStates.Add(probationState);
                    db.SaveChanges();
                }
            }

            return(probationState);
        }