uniblab icon

Untitled

uniblab | PRO | 09/27/18 05:51:58 PM UTC | 0 ⭐ | 1413 👁️ | Never ⏰ | []
C# |

2.42 KB

|

None

|

0 👍

/

0 👎

        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;
        }

Comments