예제 #1
0
        protected static List <IntermediateLearningAim> InitialLearnerTransform(ProcessLearnerCommand learnerSubmission, bool?mainAim)
        {
            var results = new List <IntermediateLearningAim>();
            var groupedLearningDeliveries = learnerSubmission.Learner.LearningDeliveries
                                            .GroupBy(ld => new
            {
                ld.LearningDeliveryValues.LearnAimRef,
                ld.LearningDeliveryValues.FworkCode,
                ld.LearningDeliveryValues.ProgType,
                ld.LearningDeliveryValues.PwayCode,
                ld.LearningDeliveryValues.StdCode
            });

            foreach (var groupedLearningDelivery in groupedLearningDeliveries)
            {
                var orderedGroupedLearningDelivery = groupedLearningDelivery.OrderByDescending(x => x.LearningDeliveryValues.LearnStartDate).ToList();
                var learningDelivery = orderedGroupedLearningDelivery.First();
                if (mainAim.HasValue && mainAim.Value != learningDelivery.IsMainAim())
                {
                    continue;
                }


                var priceEpisodes = learnerSubmission.Learner.PriceEpisodes
                                    .Where(x => orderedGroupedLearningDelivery.Any(g => g.AimSeqNumber == x.PriceEpisodeValues.PriceEpisodeAimSeqNumber))
                                    .ToList();

                if (!learningDelivery.IsMainAim())
                {
                    // Maths & English
                    var mathsAndEnglishAims = GetMathsAndEnglishAim(learnerSubmission, orderedGroupedLearningDelivery, mainAim.HasValue);
                    results.AddRange(mathsAndEnglishAims);

                    continue;
                }

                var group = priceEpisodes.Where(pe => IsCurrentAcademicYear(pe.PriceEpisodeValues, learnerSubmission.CollectionYear))
                            .GroupBy(p => p.PriceEpisodeValues.PriceEpisodeContractType);

                foreach (var episodes in group)
                {
                    var intermediateAim = new IntermediateLearningAim(learnerSubmission, episodes, orderedGroupedLearningDelivery)
                    {
                        ContractType = MappingExtensions.GetContractType(episodes.Key)
                    };
                    results.Add(intermediateAim);
                }
            }

            return(results);
        }
        public ApprenticeshipContractTypeEarningsEvent Create(string contractTypeAsString)
        {
            var contractType = MappingExtensions.GetContractType(contractTypeAsString);

            switch (contractType)
            {
            case ContractType.Act1:
                return(new ApprenticeshipContractType1EarningEvent());

            case ContractType.Act2:
                return(new ApprenticeshipContractType2EarningEvent());

            default:
                return(new ApprenticeshipContractTypeNoneEarningEvent());
            }
        }
        protected static List <IntermediateLearningAim> InitialLearnerTransform(ProcessLearnerCommand learnerSubmission, bool?mainAim)
        {
            var results = new List <IntermediateLearningAim>();

            foreach (var learningDelivery in learnerSubmission.Learner.LearningDeliveries)
            {
                if (mainAim.HasValue && mainAim.Value != learningDelivery.IsMainAim())
                {
                    continue;
                }

                var priceEpisodes = learnerSubmission.Learner.PriceEpisodes
                                    .Where(x => x.PriceEpisodeValues.PriceEpisodeAimSeqNumber == learningDelivery.AimSeqNumber)
                                    .ToList();

                if (!learningDelivery.IsMainAim())
                {
                    // Maths & English
                    var mathsAndEnglishAims = GetMathsAndEnglishAim(learnerSubmission, learningDelivery, mainAim.HasValue);
                    results.AddRange(mathsAndEnglishAims);

                    continue;
                }

                var group = priceEpisodes.GroupBy(p => p.PriceEpisodeValues.PriceEpisodeContractType);

                foreach (var episodes in group)
                {
                    var intermediateAim = new IntermediateLearningAim(learnerSubmission, episodes, learningDelivery)
                    {
                        ContractType = MappingExtensions.GetContractType(episodes.Key)
                    };
                    results.Add(intermediateAim);
                }
            }

            return(results);
        }