Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static bool CopyCourseAndClassInformationFromPreviousOccurances(string term)
- {
- bool result = false;
- try
- {
- do {
- var termEntity = JS_Term.LoadYYYYTT(term);
- if (termEntity == null) break;
- var termKey = termEntity.TermKey;
- var toCourses = JS_Course.GetAll().Where(b => (b.TermKey == termKey)).ToList();
- if ((toCourses == null) || (toCourses.Count <= 0)) break;
- foreach (var toCourse in toCourses)
- {
- var fromCourse = toCourse.PreviousOccurance;
- if (fromCourse == null) continue;
- if (toCourse.DisciplineKey == null)
- {
- toCourse.DisciplineKey = fromCourse.DisciplineKey;
- }
- toCourse.Save();
- }
- var toClasses = JS_Class.GetAll().Where(b => (string.Compare(b.ClassStat, "A", true) == 0) && (b.TermKey == termKey)).ToList();
- if ((toClasses == null) || (toClasses.Count <= 0)) break;
- foreach (var toClass in toClasses)
- {
- var fromClass = toClass.PreviousOccurance;
- if (fromClass == null) continue;
- if (string.IsNullOrEmpty(toClass.CourseDescription))
- {
- toClass.CourseDescription = fromClass.CourseDescription ?? "";
- }
- if (string.IsNullOrEmpty(toClass.ArrangedNote))
- {
- toClass.ArrangedNote = fromClass.ArrangedNote ?? "";
- }
- if (toClass.DisciplineKey == null)
- {
- toClass.DisciplineKey = fromClass.DisciplineKey;
- }
- if (toClass.HideFromListing == null)
- {
- toClass.HideFromListing = fromClass.HideFromListing;
- }
- toClass.Save();
- }
- } while (false);
- }
- catch
- {
- }
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement