Пример #1
0
        public void DeleteRegistration2(int studentId, int courseId)
        {
            LMS_GRINDEntities1 gds = new LMS_GRINDEntities1();
            Cours        course    = gds.Courses.Where(x => x.course_id == courseId).FirstOrDefault();
            StudentCours stCourse  = gds.StudentCourses.Where(x => (x.course_id == courseId) && (x.student_id == studentId)).FirstOrDefault();

            gds.StudentCourses.Remove(stCourse);
            gds.SaveChanges();
        }
Пример #2
0
        public void RegisterForCourse2(int studentId, int courseId)
        {
            LMS_GRINDEntities1 gds = new LMS_GRINDEntities1();
            Cours        course    = gds.Courses.Where(x => x.course_id == courseId).FirstOrDefault();
            StudentCours stCourse  = new StudentCours();

            stCourse.course_id    = courseId;
            stCourse.student_id   = studentId;
            stCourse.letter_grade = null;
            gds.StudentCourses.Add(stCourse);
            gds.SaveChanges();
        }
Пример #3
0
        public void DeleteCourse2(int id)
        {
            LMS_GRINDEntities1 gds = new LMS_GRINDEntities1();

            Cours           course    = gds.Courses.Where(x => x.course_id == id).FirstOrDefault();
            InstructorCours insCourse = gds.InstructorCourses.Where(x => x.course_id == id).FirstOrDefault();
            //StudentCours[] enrolledStudents = new StudentCours[32];
            var count = gds.StudentCourses.Where(x => x.course_id == id).Count();

            for (int i = 0; i < count; i++)
            {
                //remove existing enrollments to the class
                StudentCours stdCourse = gds.StudentCourses.Where(x => x.course_id == id).FirstOrDefault();
                gds.StudentCourses.Remove(stdCourse);
                gds.SaveChanges();
            }

            gds.InstructorCourses.Remove(insCourse);
            gds.Courses.Remove(course);
            gds.SaveChanges();
        }