Пример #1
0
        public void StartAdmission()
        {
            using (var entities = new Entities())
            {
                entities.Configuration.AutoDetectChangesEnabled = false;

                var majorDictionary = new Dictionary<Major, EnrollingMajor>();
                foreach (var major in entities.Majors)
                    majorDictionary.Add(major, new EnrollingMajor(major));

                this.majors = majorDictionary.Values.ToArray();

                var candidateList = new List<EnrollingCandidate>();
                foreach (var candidate in entities.Candidates)
                {
                    var options = from option in GetOptions(candidate)
                                  select majorDictionary[option];

                    var scores = GetScores(candidate);

                    Debug.Assert(options.Count() == scores.Count());

                    candidateList.Add(new EnrollingCandidate(candidate, options, scores));
                }
                this.candidates = candidateList.ToArray();

                RunAlgorithm();
                SaveResults();

                entities.SaveChanges();
            }
        }
        public EnrollingCandidate(Candidate candidate, IEnumerable<EnrollingMajor> options, IEnumerable<decimal> scores)
        {
            this.options = options.ToArray();
            this.scores = scores.ToArray();

            this.candidate = candidate;

            currentOption = -1;
        }