// Change the set of courses that a special is on. If all the courses are in the new array, changes the special to display in
// all courses.
public static void ChangeDisplayedCourses(EventDB eventDB, Id<Special> specialId, CourseDesignator[] displayedCourses)
{
// Check if the array contains all of the courses.
bool allCourses = true;
Special special = (Special) eventDB.GetSpecial(specialId).Clone();
foreach (Id<Course> courseId in eventDB.AllCourseIds) {
if (Array.IndexOf(displayedCourses, new CourseDesignator(courseId)) < 0) {
allCourses = false;
break;
}
}
if (special.kind == SpecialKind.Descriptions) {
if (Array.IndexOf(displayedCourses, CourseDesignator.AllControls) < 0)
allCourses = false; // all courses includes all controls only for descriptions.
}
special.allCourses = allCourses;
if (allCourses)
special.courses = null;
else
special.courses = displayedCourses;
eventDB.ReplaceSpecial(specialId, special);
// Descriptions special are unique per course -- enforce this.
if (special.kind == SpecialKind.Descriptions)
UpdateDescriptionCourses(eventDB, specialId);
}