public bool AddStudentToCourse(AddStudentViewModel model, int id)
        {
            if (isCourseFull(id))
            {
                return(false);
            }

            CourseStudent current = (from x in _db.CourseStudents
                                     where x.CourseID == id && x.StudentSSN == model.SSN
                                     select x).SingleOrDefault();

            //if student is on the waiting list it should be removed when added to course
            StudentInWaitinglist waiting = (from x in _db.Waitinglist
                                            where x.CourseID == id && x.StudentSSN == model.SSN
                                            select x).SingleOrDefault();

            if (waiting != null)
            {
                _db.Waitinglist.Remove(waiting);
                _db.SaveChanges();
            }

            if (current == null)
            {
                var entry = new CourseStudent {
                    CourseID   = id,
                    StudentSSN = model.SSN,
                    Active     = true
                };

                _db.CourseStudents.Add(entry);
                _db.SaveChanges();
                return(true);
            }

            else if (current.Active == false)
            {
                current.Active = true;
                _db.SaveChanges();
                return(true);
            }
            return(false);
        }
        public bool AddStudentToWaitinglist(AddStudentViewModel model, int id)
        {
            StudentInWaitinglist current = (from x in _db.Waitinglist
                                            where x.CourseID == id && x.StudentSSN == model.SSN
                                            select x).SingleOrDefault();

            var student = (from x in _db.CourseStudents
                           where x.CourseID == id && x.StudentSSN == model.SSN
                           select x).SingleOrDefault();

            if (current == null && student == null)
            {
                var entry = new StudentInWaitinglist {
                    CourseID   = id,
                    StudentSSN = model.SSN,
                };

                _db.Waitinglist.Add(entry);
                _db.SaveChanges();
                return(true);
            }

            return(false);
        }