public async Task <AppsMonthlyPaymentRulebaseInfo> GetFM36DataForAppsMonthlyPaymentReportAsync(int ukPrn, CancellationToken cancellationToken)
        {
            var appsMonthlyPaymentRulebaseInfo = new AppsMonthlyPaymentRulebaseInfo()
            {
                UkPrn = ukPrn,
                AECApprenticeshipPriceEpisodes = new List <AECApprenticeshipPriceEpisodeInfo>()
            };

            cancellationToken.ThrowIfCancellationRequested();

            List <AEC_ApprenticeshipPriceEpisode> aecApprenticeshipPriceEpisodes;

            using (var ilrContext = _ilrRulebaseContextFactory())
            {
                aecApprenticeshipPriceEpisodes = await ilrContext.AEC_ApprenticeshipPriceEpisodes.Where(x => x.UKPRN == ukPrn).ToListAsync(cancellationToken);
            }

            foreach (var aecApprenticeshipPriceEpisode in aecApprenticeshipPriceEpisodes)
            {
                var periodisedValue = new AECApprenticeshipPriceEpisodeInfo()
                {
                    LearnRefNumber            = aecApprenticeshipPriceEpisode.LearnRefNumber,
                    PriceEpisodeActualEndDate = aecApprenticeshipPriceEpisode.PriceEpisodeActualEndDate,
                    PriceEpisodeAgreeId       = aecApprenticeshipPriceEpisode.PriceEpisodeAgreeId
                };
                appsMonthlyPaymentRulebaseInfo.AECApprenticeshipPriceEpisodes.Add(periodisedValue);
            }

            return(appsMonthlyPaymentRulebaseInfo);
        }
Esempio n. 2
0
        public async Task <AppsMonthlyPaymentRulebaseInfo> GetRulebaseDataForAppsMonthlyPaymentReportAsync(
            int ukPrn,
            CancellationToken cancellationToken)
        {
            AppsMonthlyPaymentRulebaseInfo appsMonthlyPaymentRulebaseInfo = null;

            appsMonthlyPaymentRulebaseInfo = new AppsMonthlyPaymentRulebaseInfo()
            {
                UkPrn = ukPrn,
                AecApprenticeshipPriceEpisodeInfoList =
                    new List <AppsMonthlyPaymentAECApprenticeshipPriceEpisodeInfo>(),
                AecLearningDeliveryInfoList = new List <AppsMonthlyPaymentAECLearningDeliveryInfo>()
            };

            cancellationToken.ThrowIfCancellationRequested();

            using (var ilrContext = _ilrRulebaseContextFactory())
            {
                appsMonthlyPaymentRulebaseInfo.AecApprenticeshipPriceEpisodeInfoList =
                    await ilrContext?.AEC_ApprenticeshipPriceEpisodes
                    .Where(x => x.UKPRN == ukPrn)
                    .Select(ape => new AppsMonthlyPaymentAECApprenticeshipPriceEpisodeInfo
                {
                    Ukprn                           = ape.UKPRN,
                    LearnRefNumber                  = ape.LearnRefNumber,
                    PriceEpisodeIdentifier          = ape.PriceEpisodeIdentifier,
                    AimSequenceNumber               = (byte?)ape.PriceEpisodeAimSeqNumber,
                    EpisodeStartDate                = ape.EpisodeStartDate,
                    PriceEpisodeActualEndDate       = ape.PriceEpisodeActualEndDate,
                    PriceEpisodeActualEndDateIncEPA = ape.PriceEpisodeActualEndDateIncEPA,
                    //PriceEpisodeAgreeId = ape.PriceEpisodeAgreeId
                }).ToListAsync(cancellationToken);

                appsMonthlyPaymentRulebaseInfo.AecLearningDeliveryInfoList = await ilrContext.AEC_LearningDeliveries
                                                                             .Where(x => x.UKPRN == ukPrn)
                                                                             .Select(ald => new AppsMonthlyPaymentAECLearningDeliveryInfo
                {
                    Ukprn                   = ald.UKPRN,
                    LearnRefNumber          = ald.LearnRefNumber,
                    AimSequenceNumber       = (byte?)ald.AimSeqNumber,
                    LearnAimRef             = ald.LearnAimRef,
                    PlannedNumOnProgInstalm = ald.PlannedNumOnProgInstalm,
                }).ToListAsync(cancellationToken);
            }

            return(appsMonthlyPaymentRulebaseInfo);
        }