예제 #1
0
        public string CancelRegistration(int TermId)
        {
            Student student   = (Student)Session["student"];
            int     studentId = student.StudentId;

            if (dao.CancelRegistration(studentId, TermId))
            {
                return("Registration was cancelled successfully.");
            }
            else
            {
                return("An error occurred while cancelling registration.");
            }
        }
예제 #2
0
        public JsonResult CancelRegistration(int StudentId, int TermId, int RegistrationId)
        {
            bool success = dao.CancelRegistration(StudentId, TermId, RegistrationId);

            return(Json(new { success = success }));
        }
        public void CancelRegistrationTest()
        {
            // setup student
            DateTime registrationDate = new DateTime(2013, 8, 20);
            int      termId = 3, programId = 1, currentSemester = 1;

            int     studentNum = GetNextStudentNum();
            Student student    = new Student
            {
                StudentNum              = $"test{studentNum}",
                StudentLastName         = "LName",
                StudentFirstMidName     = "FName",
                StudentEmail            = "test",
                StudentHasHolds         = false,
                StudentAcademicStanding = true,
                StudentCanRegister      = true,
                StudentStartDate        = registrationDate
            };

            CentennialDA dao = new CentennialDA();

            dao.CreateStudent(ref student);
            int studentId = student.StudentId;

            dao.ProgramRegistrationNew(termId, programId, currentSemester, studentId);
            dao.CreateTranscript(studentId);

            // enroll in courses
            int coursesToEnroll = 3;

            foreach (TermCourseOption o in dao.GetTermCourses(termId))
            {
                if (coursesToEnroll == 0)
                {
                    break;
                }
                int sectionId = dao.GetSectionsForTermCourse(o.TermCourseId)[0].SectionId;
                dao.AddEnrollment(studentId, sectionId);
                coursesToEnroll--;
            }

            int numberEnrolledCourses = dao.GetNumberEnrolledCourses(studentId, termId);

            Assert.AreEqual(3, numberEnrolledCourses);

            numberEnrolledCourses = dao.GetStudentTranscript(studentId).history[0].records[0].institution.terms[0].courses.Count;
            Assert.AreEqual(3, numberEnrolledCourses);

            numberEnrolledCourses = dao.GetInvoiceInfo(studentId, termId).Invoice.tuition.Count;
            Assert.AreEqual(3, numberEnrolledCourses);

            bool hasRegistration = dao.HasValidRegistration(studentId, termId);

            Assert.IsTrue(hasRegistration);

            // cancel registration
            dao.CancelRegistration(studentId, termId);

            numberEnrolledCourses = dao.GetNumberEnrolledCourses(studentId, termId);
            Assert.AreEqual(0, numberEnrolledCourses);

            numberEnrolledCourses = dao.GetStudentTranscript(studentId).history[0].records[0].institution.terms[0].courses.Count;
            Assert.AreEqual(0, numberEnrolledCourses);

            Assert.IsNull(dao.GetInvoiceInfo(studentId, termId));

            hasRegistration = dao.HasValidRegistration(studentId, termId);
            Assert.IsFalse(hasRegistration);
        }