Example #1
0
        public bool Match(DemandingCriterias otherCriteria)
        {
            var periodMatch = IsCourse
                ? otherCriteria.From <= From && To <= otherCriteria.To
                : From <= otherCriteria.From && otherCriteria.To <= To;

            return(CourseType == otherCriteria.CourseType &&
                   Discipline == otherCriteria.Discipline &&
                   NiveauId == otherCriteria.NiveauId &&
                   periodMatch);
        }
Example #2
0
        public IEnumerable <GroupCourseDemand> GetGroupCourseDemand(Discipline discipline, int niveauId, DateTime from, DateTime to, IEnumerable <RegistrationWithParticipant> includingRegistrations = null)
        {
            var potentialParticipants         = TryAdd(_registrationRepository.GetRegisteredParticipantOverlappingPeriod(CourseType.Group, discipline, niveauId, from, to), includingRegistrations).ToArray();
            var potentialParticipantCriterias = potentialParticipants.Select(DemandingCriterias.CreateFromRegistration).ToArray();
            var potentialCourses = GetPotentialGroupCourses(discipline, niveauId, from, to);

            foreach (var potentialCourse in potentialCourses)
            {
                var courseCriterias = DemandingCriterias.CreateFromCourse(potentialCourse, _serializationService);

                var demand = potentialParticipantCriterias.Count(pp => courseCriterias.Match(pp));

                // Feature Proposal: https://github.com/benwasd/ssah/issues/54
                // Consider instructor availabilities here and compare with MaximalBoundedInstructorCount of potential and proposal courses.

                if (demand >= _demandingThresholdOptions.Value.MinParticipants)
                {
                    yield return(new GroupCourseDemand {
                        GroupCourse = potentialCourse, Demand = demand
                    });
                }
            }
        }
Example #3
0
 private static IEnumerable <DemandingCriterias> GetCriteriasAffectedFromChange(Registration changedRegistration)
 {
     return(changedRegistration.RegistrationParticipants
            .GroupBy(rp => Tuple.Create(rp.CourseType, rp.Discipline, rp.NiveauId))
            .Select(group => DemandingCriterias.CreateFromRegistration(changedRegistration, group.Key.Item1, group.Key.Item2, group.Key.Item3)));
 }