public Klas(RoosterResult.RoosterElement infoElement)
 {
     ID = infoElement.ID;
     Name = infoElement.Name;
 }
 public Lokaal(RoosterResult.RoosterElement infoElement)
 {
     Locatie = infoElement.DisplayName;
     Omschrijving = infoElement.DisplayName;
 }
        public Rooster(RoosterResult roosterResult, int id, RoosterFor @for)
        {
            RoosterFor = @for;
            var args = new RoosterArgs
            {
                Docenten = new Dictionary<int, RoosterDocent>(),
                Lokalen = new Dictionary<int, Lokaal>(),
                Klassen = new Dictionary<int, Klas>()
            };
            if (roosterResult == null || roosterResult.Result == null || roosterResult.Result.Data == null)
                throw new ArgumentException("Een aantal gegevens zijn null.", nameof(roosterResult));
            if (!roosterResult.Result.Data.ElementPeriods.ContainsKey(id))
                throw new ArgumentException("Het roosterResult object heeft niet het meegegeven klas ID", nameof(id));
            foreach (var infoElement in roosterResult.Result.Data.Elements)
                switch (infoElement.Type)
                {
                    case ElementType.Docent:
                        args.Docenten.Add(infoElement.ID, new RoosterDocent(infoElement));
                        break;
                    case ElementType.Lokaal:
                        args.Lokalen.Add(infoElement.ID, new Lokaal(infoElement));
                        break;
                    case ElementType.Klas:
                        args.Klassen.Add(infoElement.ID, new Klas(infoElement));
                        break;
                }
            Dictionary<int, List<Les>> lesPerId = new Dictionary<int, List<Les>>();
            foreach (var element in roosterResult.Result.Data.ElementPeriods[id])
            {
                var les = Les.CreateFromLesInfo(element, args);
                if (lesPerId.ContainsKey(element.LessonNumber))
                {
                    var success = false;
                    foreach(var prevLes in lesPerId[element.LessonNumber])
                    {
                        if (prevLes.EndTime == les.StartTime /*&& prevLes.Lokalen == les.Lokalen*/)
                        {
                            prevLes.EndTime = les.EndTime;
                            success = true;
                            break;
                        }
                    }
                    if (success) continue;
                }
                if (lesPerId.ContainsKey(element.LessonNumber))
                    lesPerId[element.LessonNumber].Add(les);
                else
                    lesPerId.Add(element.LessonNumber, new List<Les> { les });
                bool addLes = true;
                for(var i = Lessen.Count - 1; i >= 0; i--)
                    if (Lessen[i].StartTime == les.StartTime && Lessen[i].EndTime == les.EndTime)
                    {
                        var combinedLes = Lessen[i] as CombinedLes;
                        if (combinedLes != null)
                        {
                            combinedLes.AddLes(les);
                            addLes = false;
                        }
                        else
                        {
                            les = new CombinedLes(les, Lessen[i]);
                            Lessen.RemoveAt(i);
                        }

                    }
                if(addLes)
                    Lessen.Add(les);
            }
            Lessen = Lessen.OrderBy(l => l.StartTime).ToList();
        }
 public RoosterDocent(RoosterResult.RoosterElement element)
 {
     Naam = element.LongName;
     Code = element.Name;
 }
 internal static Les CreateFromLesInfo(RoosterResult.LesInfo info, RoosterArgs args)
 {
     var date = info.DateTime;
     var start = info.TimeSpanStartTime;
     var end = info.TimeSpanEndTime;
     var les = new Les
     {
         StartTime = new DateTime(date.Year, date.Month, date.Day, start.Hours, start.Minutes, 0),
         EndTime = new DateTime(date.Year, date.Month, date.Day, end.Hours, end.Minutes, 0),
         _omschrijving = info.LessonText,
         ID = info.LessonID,
         LessonNumber = info.LessonNumber
     };
     foreach (var element in info.Elements)
     {
         switch (element.Type)
         {
             case ElementType.Docent:
                 les.AddDocent(args.Docenten[element.ID]);
                 break;
             case ElementType.Lokaal:
                 les.AddLokaal(args.Lokalen[element.ID]);
                 break;
             case ElementType.Klas:
                 les.AddKlas(args.Klassen[element.ID]);
                 break;
         }
     }
     return les;
 }