コード例 #1
0
        private static IEnumerable <Conflict> NextClassesAtDifferentAddress(IEnumerable <FullClassRecord> allClasses)
        {
            var conflicts = new List <Conflict>();
            var message   = ConflictCompilation.ConflictDescription(ConflictCriteria.NextClassesAtDifferentAddress);

            var classes = from c in allClasses
                          orderby c.Group.Name, c.ClassTime.Day, c.ClassTime.Number
            select c;

            var prevClass = classes.ElementAt(0);

            for (int i = 1; i < allClasses.Count(); ++i)
            {
                var currClass = classes.ElementAt(i);

                if (currClass.ClassTime != null && prevClass.ClassTime != null &&
                    currClass.Classroom != null && prevClass.Classroom != null &&
                    prevClass.ClassTime.Day == currClass.ClassTime.Day &&
                    currClass.ClassTime.Number - prevClass.ClassTime.Number <= 1 &&
                    prevClass.Classroom.Address != currClass.Classroom.Address)
                {
                    var conflictingClasses = new List <FullClassRecord> {
                        prevClass, currClass
                    };
                    conflicts.Add(new Conflict(message, ConflictType.Warning, conflictingClasses));
                }
                prevClass = currClass;
            }
            return(conflicts);
        }
コード例 #2
0
        private static IEnumerable <Conflict> CardsWithBlankFields(IEnumerable <FullClassRecord> allClasses)
        {
            var message = ConflictCompilation.ConflictDescription(ConflictCriteria.CardsWithBlankFields);

            return(from c in allClasses
                   where c.Lecturer == null || c.Classroom == null || c.Subject == null
                   select new Conflict(message, ConflictType.Warning, c));
        }
コード例 #3
0
        private static IEnumerable <Conflict> LecterersOnDifferentClasses(IEnumerable <FullClassRecord> allClasses)
        {
            var message = ConflictCompilation.ConflictDescription(ConflictCriteria.LecterersOnDifferentClasses);

            return(from c in allClasses
                   where c.Lecturer != null && c.ClassTime != null
                   group c by new Tuple <Lecturer, ClassTime>(c.Lecturer, c.ClassTime) into g
                   where g.Select(c => c.Subject).Distinct().Count() > 1
                   select new Conflict(message, ConflictType.Conflict, g));
        }
コード例 #4
0
        private static IEnumerable <Conflict> GroupsInDifferentClassrooms(IEnumerable <FullClassRecord> allClasses)
        {
            var message = ConflictCompilation.ConflictDescription(ConflictCriteria.GroupsInDifferentClassrooms);

            return(from c in allClasses
                   where c.Group != null && c.ClassTime != null
                   group c by new Tuple <Group, ClassTime>(c.Group, c.ClassTime) into g
                   where g.Count() > 1
                   select new Conflict(message, ConflictType.Conflict, g));
        }
コード例 #5
0
        private static IEnumerable <Conflict> GreaterThanFourClassesPerDay(IEnumerable <FullClassRecord> allClasses)
        {
            var message = ConflictCompilation.ConflictDescription(ConflictCriteria.GreaterThanFourClassesPerDay);

            return(from c in allClasses
                   where c.Group != null && c.ClassTime != null
                   group c by new Tuple <Group, Weekdays>(c.Group, c.ClassTime.Day) into g
                   where g.Count() > 4
                   select new Conflict(message, ConflictType.Warning, g));
        }