public ActionResult CourseDetail(int id)
        {
            Dictionary <string, object> model = new Dictionary <string, object>();
            Course selectedCourse             = Course.Find(id);

            List <Student> courseStudents = selectedCourse.GetStudents();

            List <Student> allStudents = Student.GetAll();

            model.Add("course", selectedCourse);
            model.Add("courseStudents", courseStudents);
            model.Add("allStudents", allStudents);

            return(View(model));
        }
Beispiel #2
0
        public void Test_Delete_DeletesStudentAssociationsFromDatabase()
        {
            //Arrange
            Course testCourse = new Course("Intro to CS");

            testCourse.Save();

            string  testName    = "Accounting";
            string  testDate    = "01/03/2017";
            Student testStudent = new Student(testName, testDate);

            testStudent.Save();

            //Act
            testStudent.AddCourse(testCourse);
            testStudent.Delete();

            List <Student> resultCourseStudents = testCourse.GetStudents();
            List <Student> testCourseStudents   = new List <Student> {
            };

            //Assert
            Assert.Equal(testCourseStudents, resultCourseStudents);
        }
        public void Test_GetStudents_RetrievesAllStudentsWithCourse()
        {
            //Arrange
            Course testCourse = new Course("Intro To CS");

            testCourse.Save();
            Student firstStudent = new Student("Matt Caswell", "04/01/2017", testCourse.GetId());

            firstStudent.Save();
            Student secondStudent = new Student("Jasper", "07/24/2017", testCourse.GetId());

            secondStudent.Save();

            //Act
            testCourse.AddStudent(firstStudent);
            testCourse.AddStudent(secondStudent);
            List <Student> testStudentList = new List <Student> {
                firstStudent, secondStudent
            };
            List <Student> resultStudentList = testCourse.GetStudents();

            //Assert
            Assert.Equal(testStudentList, resultStudentList);
        }