Beispiel #1
0
        private static Change ParseLessonNode(XmlNode schoolNode, XmlNode classNode, XmlNode dateNode, XmlNode lessonNode)
        {
            XmlNode oldNode = lessonNode.ChildNodes.Item("original");
            XmlNode newNode = lessonNode.ChildNodes.Item("substitute");

            var oldSubjectNode = oldNode.ChildNodes.Item("subject");
            var newSubjectNode = newNode.ChildNodes.Item("subject");

            var oldTeacherNode = oldNode.ChildNodes.Item("tutor");
            var newTeacherNode = newNode.ChildNodes.Item("tutor");

            var stringDay = dateNode.Attributes["timestamp"]?.Value;
            var day       = DateTimeOffset.FromUnixTimeSeconds(Convert.ToInt64(stringDay) + TimeZoneOffset).DateTime;
            var hours     = oldNode.ChildText("hours");

            var schoolClass = new SchoolClass(schoolNode.Attributes["name"]?.Value,
                                              classNode.Attributes["name"]?.Value);

            var oldLesson = new Lesson(new Subject(oldSubjectNode?.ChildText("shortcut"),
                                                   oldSubjectNode?.ChildText("name")),
                                       new Teacher(oldTeacherNode?.ChildText("firstname"),
                                                   oldTeacherNode?.ChildText("lastname"),
                                                   oldTeacherNode?.ChildText("shortcut")),
                                       oldNode.ChildText("room"));

            var attribute = newNode.ChildText("attribute");
            var info      = newNode.ChildText("info");

            Subject newSubject = null;

            if (newSubjectNode != null)
            {
                newSubject = new Subject(newSubjectNode.ChildText("shortcut"),
                                         newSubjectNode.ChildText("name"));
            }

            Teacher newTeacher = null;

            if (newTeacherNode != null)
            {
                newTeacher = new Teacher(newTeacherNode.ChildText("firstname"),
                                         newTeacherNode.ChildText("lastname"),
                                         newTeacherNode.ChildText("shortcut"));
            }

            var newLesson = new Lesson(newSubject,
                                       newTeacher,
                                       newNode.ChildText("room"));

            return(new Change(schoolClass, day, hours, oldLesson, newLesson, attribute, info));
        }
Beispiel #2
0
        public async Task BookmarkSchoolClass(SchoolClass schoolClass, bool bookmark)
        {
            var i = IndexOfSchoolClassBookmark(schoolClass);

            Debug.Assert(i >= 0, string.Format("School class bookmark {0} schould exist", schoolClass));

            var oldBookmark = SchoolClassBookmarks[i];
            var newBookmark = new SchoolClassBookmark(schoolClass,
                                                      bookmark,
                                                      oldBookmark.SchoolBookmarked);

            UpdateSchoolClassBookmark(newBookmark);
            UpdateBookmarkedVplan();

            await PersistSchoolClassBookmarks();
        }
Beispiel #3
0
        public int CompareTo(object obj)
        {
            if (obj == null)
            {
                return(1);
            }
            SchoolClass schoolClass = obj as SchoolClass;

            if (schoolClass != null)
            {
                return(string.Compare(Name, schoolClass.Name, StringComparison.Ordinal));
            }
            else
            {
                throw new ArgumentException("Object is not a SchoolClass");
            }
        }
 public SchoolClassBookmark(SchoolClass schoolClass, bool bookmarked, bool schoolBookmarked)
 {
     SchoolClass      = schoolClass;
     Bookmarked       = bookmarked;
     SchoolBookmarked = schoolBookmarked;
 }
Beispiel #5
0
        int IndexOfSchoolClassBookmark(SchoolClass schoolClass)
        {
            var dummyBookmark = new SchoolClassBookmark(schoolClass, false, false);

            return(SchoolClassBookmarks.IndexOf(dummyBookmark));
        }