PurplePen.EventDB.AddCourseControl C# (CSharp) Method

AddCourseControl() public method

public AddCourseControl ( CourseControl courseControl ) : Id
courseControl CourseControl
return Id
        public Id<CourseControl> AddCourseControl(CourseControl courseControl)
        {
            return courseControlStore.Add(courseControl);
        }

Usage Example

Example #1
0
        // Add a new course control to a course. Adds a new CourseControl referencing controlId into courseId. The place to insert is
        // given by courseControl1 and courseControl2. These control should have been gotten by calling FindControlInsertionPoint.
        public static Id<CourseControl> AddCourseControl(EventDB eventDB, Id<ControlPoint> controlId, Id<Course> courseId, Id<CourseControl> courseControl1, Id<CourseControl> courseControl2)
        {
            CourseControl newCourseControl;
            Id<CourseControl> newCourseControlId;

            // When adding a new course controls, they fit into variations fine because we are never adding or changing an split, just
            // fitting into existing splits.

            if (courseControl1.IsNone) {
                // Adding at start.
                Course course = (Course) eventDB.GetCourse(courseId).Clone();
                Debug.Assert(courseControl2 == course.firstCourseControl);
                newCourseControl = new CourseControl(controlId, course.firstCourseControl);
                newCourseControlId = eventDB.AddCourseControl(newCourseControl);
                course.firstCourseControl = newCourseControlId;
                eventDB.ReplaceCourse(courseId, course);
            }
            else {
                // Adding after courseControl1.
                CourseControl before = (CourseControl) eventDB.GetCourseControl(courseControl1).Clone();
                Debug.Assert(courseControl2 == before.nextCourseControl);
                newCourseControl = new CourseControl(controlId, before.nextCourseControl);
                newCourseControlId = eventDB.AddCourseControl(newCourseControl);
                before.nextCourseControl = newCourseControlId;
                eventDB.ReplaceCourseControl(courseControl1, before);
            }

            return newCourseControlId;
        }
All Usage Examples Of PurplePen.EventDB::AddCourseControl