public ActionResult SaveClassDetails(int TermCourseId, int SectionId, int ClassId, string SectionNum, bool ClassIsLecture, int InstructorId, int RoomId, int ClassStartTime, int ClassEndTime) { bool isSuccessful = false; if (ClassId != 0) { // both section and class already exist isSuccessful = dao.UpdateSection(SectionId, SectionNum); if (isSuccessful) { isSuccessful = dao.UpdateClass(new ClassInfo { ClassId = ClassId, ClassIsLecture = ClassIsLecture, InstructorId = InstructorId, RoomId = RoomId, ClassStartTime = ClassStartTime, ClassEndTime = ClassEndTime }); } } else if (SectionId != 0) { // section already exists, but class doesn't exist yet isSuccessful = dao.UpdateSection(SectionId, SectionNum); if (isSuccessful) { isSuccessful = dao.CreateClassForSection(SectionId, new ClassInfo { ClassIsLecture = ClassIsLecture, InstructorId = InstructorId, RoomId = RoomId, ClassStartTime = ClassStartTime, ClassEndTime = ClassEndTime }); } } else { // neither section nor class exist yet SectionId = dao.CreateSectionForTermCourse(TermCourseId, SectionNum); if (SectionId != 0) { isSuccessful = dao.CreateClassForSection(SectionId, new ClassInfo { ClassIsLecture = ClassIsLecture, InstructorId = InstructorId, RoomId = RoomId, ClassStartTime = ClassStartTime, ClassEndTime = ClassEndTime }); } } return(RedirectToAction("EditSectionDetails", new { TermCourseId = TermCourseId })); }