Example #1
0
 /// <summary>
 /// Der Konstruktor.
 /// </summary>
 /// <param name="subject">Das Fach, in dem diese Hausaufgabe auf ist.</param>
 public Homework(Subject subject)
 {
     this.subject = subject;
     this.fromDate = DateTime.Now.Date;
     this.toDate = DateTime.Today.Date.AddDays(1);
     this.text = "";
 }
Example #2
0
        public bool RemoveSubject(Subject item)
        {
            var lessons = GetAllLessons(item);
            var homeworks = Homeworks.Where(p => p.Subject == item);

            foreach (Lesson lesson in lessons)
            {
                if (lesson.DataEvenWeek.Subject == item)
                    lesson.DataEvenWeek.Subject = Subject.None;
                if (lesson.DataOddWeek.Subject == item)
                    lesson.DataOddWeek.Subject = Subject.None;
            }

            List<Homework> homeworksToRemove = new List<Homework>(homeworks);
            foreach (Homework homework in homeworksToRemove)
                Homeworks.Remove(homework);

            this.Subjects.Remove(item);
            return true;
        }
            public ColorViewModel(string color, Subject subject, Timetable timetable)
            {
                this.Color = color;

                var subjects = timetable.Subjects.Where(p => p.Color == color && p != subject).Select(p => p.Name).OrderBy(p => p);

                int maxAmount = 3;

                if (!subjects.Any())
                    OtherSubjects = "";
                else
                {
                    OtherSubjects = string.Join("," + Environment.NewLine, subjects.Take(maxAmount));

                    if (subjects.Count() > 3)
                        OtherSubjects += "," + Environment.NewLine + "...";
                }

                this.subject = subject;
                subject.PropertyChanged += subject_PropertyChanged;
            }
Example #4
0
 public SubjectRoom(Subject subject, string room)
 {
     this.room = room;
     this.subject = subject;
     subject.PropertyChanged += SubjectPropertyChanged;
 }
        public EditSubjectPageViewModel(Subject subject, Timetable timetable)
            : base(subject)
        {
            this.oldName = subject.Name;
            this.Teachers = new ReadOnlyCollection<string>(timetable.Subjects.Select(p => p.Teacher).Distinct().ToList());

            this.AvailableColors = new ReadOnlyCollection<ColorViewModel>(new String[]
            {
                "A4C400",
                "60A917",
                "008A00",
                "00ABA9",

                "1BA1E2",
                "3E65FF",
                "6A00FF",
                "AA00FF",

                "F472D0",
                "D80073",
                "A20025",
                "E51400",

                "FA6800",
                "F0A30A",
                "E3C800",
                "825A2C",

                "6D8764",
                "647687",
                "76608A",
                "87794E"
            }.Select(p => new ColorViewModel(p, subject, timetable)).ToList());
        }
Example #6
0
 public Subject AddSubject(string name)
 {
     Subject returnValue = new Subject(name);
     this.Subjects.Add(returnValue);
     return returnValue;
 }
Example #7
0
 /// <summary>
 /// Versucht den Raum zu ermitteln, in dem das Fach stattfinden könnte.
 /// </summary>
 /// <param name="subject">Das Fach für das der Raum ermittelt wird.</param>
 /// <returns>Den Namen des Raumes oder einen leeren String.</returns>
 public string GetDefaultRoom(Subject subject)
 {
     foreach (Day day in this.Days)
     {
         foreach (Lesson lesson in day.Lessons)
         {
             if (lesson.DataEvenWeek.Subject == subject)
                 return lesson.DataEvenWeek.Room;
             else if (lesson.DataOddWeek.Subject == subject)
                 return lesson.DataOddWeek.Room;
         }
     }
     return "";
 }
Example #8
0
        /// <summary>
        /// Sucht nach dem nächsten Termin andem ein bestimmtes Fach stattfindet, wenn kein Wert gefunden wurde wird Morgen zurückgeliefert.
        /// </summary>
        /// <param name="subject">Das Fach nachdem gesucht werden soll.</param>
        /// <param name="isOddWeek">Soll in einer ungeraden oder einer graden Woche gearbeitet werden.</param>
        /// <returns>Das Datum, andem das Fach wieder stattfindet, wennn keines gefunden der morgige Tag.</returns>
        public DateTime GetNextDate(Subject subject, bool isOddWeek)
        {
            DateTime tomorrow = DateTime.Today.AddDays(1);

            //Für die nächsten 2 Wochen gucken, wegen A/B Wochen.
            var listedLessons = GetListedLessons(tomorrow, tomorrow.AddDays(13), isOddWeek);

            foreach (var day in listedLessons)
            {
                if (day.Value.Any(p => p.Value.Subject == subject))
                    return day.Key;
            }

            //Ansonsten den morgigen Tag verwenden
            return tomorrow;
        }
Example #9
0
 public IEnumerable<Lesson> GetAllLessons(Subject subject)
 {
     return this.Days.SelectMany(p => p.Lessons.Where(q => (q.DataOddWeek.Subject == subject) || (q.DataEvenWeek.Subject == subject)));
 }