public void Subscribe_SubscribeStudent_StudentAdded() { Student student = generator.CreateStudent(testlastnamestudent, testfirstnamestudent, testloginstudent, testpasswordstudent); Course course = generator.CreateCourse(testcoursetitle, testdepartmentname, testlastnameinstructor, testfirstnameinstructor, testlogininstructor, testpasswordinstructor); StudentEnrollmentBL.Subscribe(student.ID, course.CourseID); var enrollmentexist = DBUtils.db.Enrollments.FirstOrDefault(e => e.StudentID == student.ID && e.CourseID == course.CourseID); Assert.NotNull(enrollmentexist); }
public ActionResult Subscribe(int id) { int studentID = (int)TempData["StudentID"]; if (StudentEnrollmentBL.CourseExists(id) && StudentEnrollmentBL.CanStudentSubscribe(studentID, id)) { StudentEnrollmentBL.Subscribe(studentID, id); } else if (StudentEnrollmentBL.CourseExists(id) && !StudentEnrollmentBL.CanStudentSubscribe(studentID, id)) { TempData["Error"] = "You already subscribed to this course"; } else { TempData["Error"] = "This course doesn't exist"; } TempData["StudentID"] = TempData["StudentID"]; return(RedirectToAction("Details", new { controller = "Student", action = "Details", id = studentID })); }