public async Task <IReadOnlyCollection <LARSFrameworkDesktop> > RetrieveAsync(CancellationToken cancellationToken)
        {
            using (var context = _larsContextFactory.Create())
            {
                var larsFrameworks = await context.LARS_Frameworks
                                     .Include(l => l.LarsApprenticeshipFworkFundings)
                                     .Include(l => l.LarsFrameworkCmnComps)
                                     .ToListAsync(cancellationToken);

                _referenceDataStatisticsService.AddRecordCount(ReferenceDataSummaryConstants.LarsFrameworks, larsFrameworks.Count);
                _referenceDataStatisticsService.AddRecordCount(ReferenceDataSummaryConstants.LarsFrameworksCommonComponents, larsFrameworks.SelectMany(lf => lf.LarsFrameworkCmnComps).Count());
                _referenceDataStatisticsService.AddRecordCount(ReferenceDataSummaryConstants.LarsFrameworksApprenticeshipFunding, larsFrameworks.SelectMany(lf => lf.LarsApprenticeshipFworkFundings).Count());

                return(larsFrameworks
                       .Select(lf => new LARSFrameworkDesktop
                {
                    FworkCode = lf.FworkCode,
                    ProgType = lf.ProgType,
                    PwayCode = lf.PwayCode,
                    EffectiveFromNullable = lf.EffectiveFrom,
                    EffectiveTo = lf.EffectiveTo,
                    LARSFrameworkApprenticeshipFundings = lf.LarsApprenticeshipFworkFundings.Select(laf =>
                                                                                                    new LARSFrameworkApprenticeshipFunding
                    {
                        BandNumber = laf.BandNumber,
                        CareLeaverAdditionalPayment = laf.CareLeaverAdditionalPayment,
                        CoreGovContributionCap = laf.CoreGovContributionCap,
                        Duration = laf.Duration,
                        EffectiveFrom = laf.EffectiveFrom,
                        EffectiveTo = laf.EffectiveTo,
                        FundableWithoutEmployer = laf.FundableWithoutEmployer,
                        FundingCategory = laf.FundingCategory,
                        MaxEmployerLevyCap = laf.MaxEmployerLevyCap,
                        ReservedValue2 = laf.ReservedValue2,
                        ReservedValue3 = laf.ReservedValue3,
                        SixteenToEighteenEmployerAdditionalPayment = laf._1618employerAdditionalPayment,
                        SixteenToEighteenFrameworkUplift = laf._1618frameworkUplift,
                        SixteenToEighteenIncentive = laf._1618incentive,
                        SixteenToEighteenProviderAdditionalPayment = laf._1618providerAdditionalPayment,
                    }).ToList(),
                    LARSFrameworkCommonComponents = lf.LarsFrameworkCmnComps.Select(lcc =>
                                                                                    new LARSFrameworkCommonComponent
                    {
                        CommonComponent = lcc.CommonComponent,
                        EffectiveFrom = lcc.EffectiveFrom,
                        EffectiveTo = lcc.EffectiveTo,
                    }).ToList(),
                }).ToList());
            }
        }
Exemple #2
0
        public async Task <IReadOnlyCollection <Postcode> > RetrieveAsync(CancellationToken cancellationToken)
        {
            var masterPostcodes          = RetrieveMasterPostcodes(cancellationToken);
            var sfaAreaCosts             = RetrieveSfaAreaCosts(cancellationToken);
            var sfaPostcodeDisadvantages = RetrieveSfaPostcodeDisadvantages(cancellationToken);
            var efaPostcodeDisadvantages = RetrieveEfaPostcodeDisadvantages(cancellationToken);
            var dasPostcodeDisadvantages = RetrieveDasPostcodeDisadvantages(cancellationToken);
            var onsData = RetrieveOnsData(cancellationToken);

            _referenceDataStatisticsService.AddRecordCount(ReferenceDataSummaryConstants.PostcodesONSData, onsData.Result.SelectMany(x => x.Value).Count());
            _referenceDataStatisticsService.AddRecordCount(ReferenceDataSummaryConstants.PostcodesDASDisadvantages, dasPostcodeDisadvantages.Result.SelectMany(x => x.Value).Count());
            _referenceDataStatisticsService.AddRecordCount(ReferenceDataSummaryConstants.PostcodesEFADisadvantages, efaPostcodeDisadvantages.Result.SelectMany(x => x.Value).Count());
            _referenceDataStatisticsService.AddRecordCount(ReferenceDataSummaryConstants.PostcodesSFADisadvantages, sfaPostcodeDisadvantages.Result.SelectMany(x => x.Value).Count());
            _referenceDataStatisticsService.AddRecordCount(ReferenceDataSummaryConstants.PostcodesSFAAreaCosts, sfaAreaCosts.Result.SelectMany(x => x.Value).Count());

            var taskList = new List <Task>
            {
                masterPostcodes,
                sfaAreaCosts,
                sfaPostcodeDisadvantages,
                efaPostcodeDisadvantages,
                dasPostcodeDisadvantages,
                onsData
            };

            await Task.WhenAll(taskList);

            return(masterPostcodes.Result
                   .Select(postcode => new Postcode()
            {
                PostCode = postcode,
                SfaDisadvantages = sfaPostcodeDisadvantages.Result.TryGetValue(postcode, out var sfaDisadValued)
                        ? sfaDisadValued
                        : null,
                SfaAreaCosts = sfaAreaCosts.Result.TryGetValue(postcode, out var sfaAreaCostValue)
                        ? sfaAreaCostValue
                        : null,
                DasDisadvantages = dasPostcodeDisadvantages.Result.TryGetValue(postcode, out var dasDisadValue)
                        ? dasDisadValue
                        : null,
                EfaDisadvantages = efaPostcodeDisadvantages.Result.TryGetValue(postcode, out var efaDisadValue)
                        ? efaDisadValue
                        : null,
                ONSData = onsData.Result.TryGetValue(postcode, out var onsValue) ? onsValue : null,
            }).ToList());
        public async Task <IReadOnlyCollection <LARSLearningDelivery> > RetrieveAsync(CancellationToken cancellationToken)
        {
            using (var context = _larsContextFactory.Create())
            {
                var learningDeliveries = await BuildLARSLearningDelvieries(context, cancellationToken);

                _referenceDataStatisticsService.AddRecordCount(ReferenceDataSummaryConstants.LarsLearningDeliveries, learningDeliveries.Count);

                var larsAnnualValuesDictionary = await BuildLARSAnnualValueDictionary(context, cancellationToken);

                _referenceDataStatisticsService.AddRecordCount(ReferenceDataSummaryConstants.LarsAnnualValues, larsAnnualValuesDictionary.SelectMany(x => x.Value).Count());

                var larsLearningDeliveryCategoriesDictionary = await BuildLARSLearningDeliveryCategoryDictionary(context, cancellationToken);

                _referenceDataStatisticsService.AddRecordCount(ReferenceDataSummaryConstants.LarsLearningDeliveryategories, larsLearningDeliveryCategoriesDictionary.SelectMany(x => x.Value).Count());

                var larsFundingsDictionary = await BuildLARSFundingDictionary(context, cancellationToken);

                _referenceDataStatisticsService.AddRecordCount(ReferenceDataSummaryConstants.LarsFunding, larsFundingsDictionary.SelectMany(x => x.Value).Count());

                var larsValiditiesDictionary = await BuildLARSValidityDictionary(context, cancellationToken);

                _referenceDataStatisticsService.AddRecordCount(ReferenceDataSummaryConstants.LarsValidities, larsValiditiesDictionary.SelectMany(x => x.Value).Count());

                var larsSectorSubjectAreaTier2Dictionary = await BuildLARSSectorSubjectAreaTier2Dictionary(context, cancellationToken);

                var defaultLarsAnnualValues = new List <LARSAnnualValue>();
                var defaultLarsLearningDeliveryCategories = new List <LARSLearningDeliveryCategory>();
                var defaultLarsFundings   = new List <LARSFunding>();
                var defaultLarsValidities = new List <LARSValidity>();
                var defaultLarsFrameworks = new List <LARSFramework>();

                foreach (var learningDelivery in learningDeliveries)
                {
                    learningDelivery.SectorSubjectAreaTier2Desc     = larsSectorSubjectAreaTier2Dictionary.TryGetValue(learningDelivery.SectorSubjectAreaTier2.GetValueOrDefault(), out var sectorSubjectAreaTier2Desc) ? sectorSubjectAreaTier2Desc : string.Empty;
                    learningDelivery.LARSAnnualValues               = larsAnnualValuesDictionary.TryGetValue(learningDelivery.LearnAimRef, out var annualValues) ? annualValues : defaultLarsAnnualValues;
                    learningDelivery.LARSLearningDeliveryCategories = larsLearningDeliveryCategoriesDictionary.TryGetValue(learningDelivery.LearnAimRef, out var categories) ? categories : defaultLarsLearningDeliveryCategories;
                    learningDelivery.LARSFundings   = larsFundingsDictionary.TryGetValue(learningDelivery.LearnAimRef, out var fundings) ? fundings : defaultLarsFundings;
                    learningDelivery.LARSValidities = larsValiditiesDictionary.TryGetValue(learningDelivery.LearnAimRef, out var validities) ? validities : defaultLarsValidities;
                }

                return(learningDeliveries);
            }
        }
        public async Task <DevolvedPostcodes> RetrieveAsync(CancellationToken cancellationToken)
        {
            using (var context = _postcodesContextFactory.Create())
            {
                var mcaGlaSofLookups = await RetrieveMcaGlaLookups(context, cancellationToken);

                _referenceDataStatisticsService.AddRecordCount(ReferenceDataSummaryConstants.McaSofLookups, mcaGlaSofLookups.Count);

                var devolvedPostcodesList = await RetrieveDevolvedPostcodes(cancellationToken);

                _referenceDataStatisticsService.AddRecordCount(ReferenceDataSummaryConstants.DevolvedPostcodes, devolvedPostcodesList.Count);

                return(new DevolvedPostcodes
                {
                    McaGlaSofLookups = mcaGlaSofLookups,
                    Postcodes = devolvedPostcodesList
                });
            }
        }
        public async Task <IReadOnlyCollection <Organisation> > RetrieveAsync(CancellationToken cancellationToken)
        {
            using (var context = _organisationsFactory.Create())
            {
                var specResourcesForUkprnDictionary = await BuildCampusIdSpecResourceDictionary(context, cancellationToken);

                var campusIdentifiersDictionary = await BuildCampusIdentifiersDictionary(specResourcesForUkprnDictionary, context, cancellationToken);

                var postcodeSpecResourcesDictionary = await BuildPostcodeSpecResDictionary(context, cancellationToken);

                var shortTermFundingInitiativesDictionary = await BuildShortTermFundingInitiativesDictionary(context, cancellationToken);

                var orgs = await context
                           .MasterOrganisations
                           .Include(mo => mo.OrgDetail)
                           .Include(mo => mo.OrgPartnerUkprns)
                           .Include(mo => mo.OrgFundings)
                           .Include(mo => mo.ConditionOfFundingRemovals)
                           .ToListAsync(cancellationToken);

                _referenceDataStatisticsService.AddRecordCount(ReferenceDataSummaryConstants.OrganisationsDetails, orgs.Select(o => o.OrgDetail).Count());
                _referenceDataStatisticsService.AddRecordCount(ReferenceDataSummaryConstants.OrganisaitonsFunding, orgs.SelectMany(o => o.OrgFundings).Count());
                _referenceDataStatisticsService.AddRecordCount(ReferenceDataSummaryConstants.CoFRemovals, orgs.SelectMany(o => o.ConditionOfFundingRemovals).Count());
                _referenceDataStatisticsService.AddRecordCount(ReferenceDataSummaryConstants.CampusIdentifiers, campusIdentifiersDictionary.SelectMany(x => x.Value).Count());
                _referenceDataStatisticsService.AddRecordCount(ReferenceDataSummaryConstants.ShortTermFundingInitiatives, shortTermFundingInitiativesDictionary.SelectMany(x => x.Value).Count());
                _referenceDataStatisticsService.AddRecordCount(ReferenceDataSummaryConstants.PostcodeSpecialistResources, specResourcesForUkprnDictionary.SelectMany(x => x.Value).Count());

                return(BuildOrganisations(orgs, specResourcesForUkprnDictionary, campusIdentifiersDictionary, postcodeSpecResourcesDictionary, shortTermFundingInitiativesDictionary));
            }
        }
        public async Task <MetaData> RetrieveDesktopMetaDataAsync(CancellationToken cancellationToken)
        {
            var metaData = await RetrieveAsync(cancellationToken);

            _referenceDataStatisticsService.AddRecordCount(ReferenceDataSummaryConstants.ValidationErrors, metaData.ValidationErrors.Count);

            metaData.ReferenceDataVersions.EasFileDetails = new EasFileDetails
            {
                FileName = _easFileName
            };

            return(metaData);
        }
Exemple #7
0
        public async Task <IReadOnlyCollection <EPAOrganisation> > RetrieveAsync(CancellationToken cancellationToken)
        {
            using (var context = _epaContextFactory.Create())
            {
                var epaOrgs = await context?
                              .Periods?
                              .Select(epa => new EPAOrganisation
                {
                    ID            = epa.OrganisationId.ToUpperCase(),
                    Standard      = epa.StandardCode,
                    EffectiveFrom = epa.EffectiveFrom,
                    EffectiveTo   = epa.EffectiveTo,
                }).ToListAsync(cancellationToken);

                _referenceDataStatisticsService.AddRecordCount(ReferenceDataSummaryConstants.EPAOrganisations, epaOrgs.Count());

                return(epaOrgs);
            }
        }
Exemple #8
0
        public async Task <IReadOnlyCollection <Employer> > RetrieveAsync(CancellationToken cancellationToken)
        {
            using (var context = _employersContextFactory.Create())
            {
                var largeEmployers = await context.LargeEmployers.ToListAsync(cancellationToken);

                _referenceDataStatisticsService.AddRecordCount(ReferenceDataSummaryConstants.LargeEmployers, largeEmployers.Count);

                return(largeEmployers.GroupBy(le => le.Ern)
                       .Select(e => new Employer
                {
                    ERN = e.Key,
                    LargeEmployerEffectiveDates = e.Select(le => new LargeEmployerEffectiveDates
                    {
                        EffectiveFrom = le.EffectiveFrom,
                        EffectiveTo = le.EffectiveTo,
                    }).ToList(),
                }).ToList());
            }
        }
        public async Task <IReadOnlyCollection <LARSFrameworkAimDesktop> > RetrieveAsync(CancellationToken cancellationToken)
        {
            using (var context = _larsContextFactory.Create())
            {
                var larsFrameworkAims = await context.LARS_FrameworkAims.ToListAsync(cancellationToken);

                _referenceDataStatisticsService.AddRecordCount(ReferenceDataSummaryConstants.LarsFrameworkAims, larsFrameworkAims.Count);

                return(larsFrameworkAims
                       .Select(lf => new LARSFrameworkAimDesktop
                {
                    FworkCode = lf.FworkCode,
                    ProgType = lf.ProgType,
                    PwayCode = lf.PwayCode,
                    FrameworkComponentType = lf.FrameworkComponentType,
                    LearnAimRef = lf.LearnAimRef.ToUpperCase(),
                    EffectiveFrom = lf.EffectiveFrom,
                    EffectiveTo = lf.EffectiveTo,
                }).ToList());
            }
        }
Exemple #10
0
        public async Task <IReadOnlyCollection <LARSStandard> > RetrieveAsync(CancellationToken cancellationToken)
        {
            using (var context = _larsContextFactory.Create())
            {
                var larsStandards = await context.LARS_Standards
                                    .Include(l => l.LarsApprenticeshipStdFundings)
                                    .Include(l => l.LarsStandardCommonComponents)
                                    .Include(l => l.LarsStandardFundings)
                                    .Include(l => l.LarsStandardValidities)
                                    .ToListAsync(cancellationToken);

                _referenceDataStatisticsService.AddRecordCount(ReferenceDataSummaryConstants.LarsStandards, larsStandards.Count);
                _referenceDataStatisticsService.AddRecordCount(ReferenceDataSummaryConstants.LarsStandardApprenticeshipFunding, larsStandards.SelectMany(ls => ls.LarsApprenticeshipStdFundings).Count());
                _referenceDataStatisticsService.AddRecordCount(ReferenceDataSummaryConstants.LarsStandardCommonComponents, larsStandards.SelectMany(ls => ls.LarsStandardCommonComponents).Count());
                _referenceDataStatisticsService.AddRecordCount(ReferenceDataSummaryConstants.LarsStandardFundings, larsStandards.SelectMany(ls => ls.LarsStandardFundings).Count());
                _referenceDataStatisticsService.AddRecordCount(ReferenceDataSummaryConstants.LarsStandardValidities, larsStandards.SelectMany(ls => ls.LarsStandardValidities).Count());

                return(larsStandards
                       .Select(
                           ls => new LARSStandard
                {
                    StandardCode = ls.StandardCode,
                    StandardSectorCode = ls.StandardSectorCode,
                    NotionalEndLevel = ls.NotionalEndLevel,
                    EffectiveFrom = ls.EffectiveFrom.Value,
                    EffectiveTo = ls.EffectiveTo,
                    LastDateStarts = ls.LastDateStarts,
                    LARSStandardApprenticeshipFundings = ls.LarsApprenticeshipStdFundings.Select(lsa =>
                                                                                                 new LARSStandardApprenticeshipFunding
                    {
                        BandNumber = lsa.BandNumber,
                        CareLeaverAdditionalPayment = lsa.CareLeaverAdditionalPayment,
                        CoreGovContributionCap = lsa.CoreGovContributionCap,
                        Duration = lsa.Duration,
                        EffectiveFrom = lsa.EffectiveFrom,
                        EffectiveTo = lsa.EffectiveTo,
                        FundableWithoutEmployer = lsa.FundableWithoutEmployer,
                        FundingCategory = lsa.FundingCategory,
                        MaxEmployerLevyCap = lsa.MaxEmployerLevyCap,
                        ProgType = lsa.ProgType,
                        PwayCode = lsa.PwayCode,
                        ReservedValue2 = lsa.ReservedValue2,
                        ReservedValue3 = lsa.ReservedValue3,
                        SixteenToEighteenEmployerAdditionalPayment = lsa._1618employerAdditionalPayment,
                        SixteenToEighteenFrameworkUplift = lsa._1618frameworkUplift,
                        SixteenToEighteenIncentive = lsa._1618incentive,
                        SixteenToEighteenProviderAdditionalPayment = lsa._1618providerAdditionalPayment,
                    }).ToList(),
                    LARSStandardCommonComponents = ls.LarsStandardCommonComponents.Select(lsc =>
                                                                                          new LARSStandardCommonComponent
                    {
                        CommonComponent = lsc.CommonComponent,
                        EffectiveFrom = lsc.EffectiveFrom,
                        EffectiveTo = lsc.EffectiveTo,
                    }).ToList(),
                    LARSStandardFundings = ls.LarsStandardFundings.Select(lsf =>
                                                                          new LARSStandardFunding
                    {
                        AchievementIncentive = lsf.AchievementIncentive,
                        BandNumber = lsf.BandNumber,
                        CoreGovContributionCap = lsf.CoreGovContributionCap,
                        EffectiveFrom = lsf.EffectiveFrom,
                        EffectiveTo = lsf.EffectiveTo,
                        FundableWithoutEmployer = lsf.FundableWithoutEmployer,
                        FundingCategory = lsf.FundingCategory,
                        SixteenToEighteenIncentive = lsf._1618incentive,
                        SmallBusinessIncentive = lsf.SmallBusinessIncentive,
                    }).ToList(),
                    LARSStandardValidities = ls.LarsStandardValidities.Select(lsv =>
                                                                              new LARSStandardValidity
                    {
                        EffectiveFrom = lsv.StartDate,
                        EffectiveTo = lsv.EndDate,
                        LastNewStartDate = lsv.LastNewStartDate,
                        ValidityCategory = lsv.ValidityCategory,
                    }).ToList(),
                }).ToList());
            }
        }