private static void UpdateFundingLineDistributionPeriods(BatchProfilingResponseModel response,
                                                                 ProfilingBatch batch)
        {
            DistributionPeriod[] distributionPeriods = response.DistributionPeriods.Select(_ => new DistributionPeriod
            {
                DistributionPeriodId = _.DistributionPeriodCode,
                Value          = _.Value,
                ProfilePeriods = response.DeliveryProfilePeriods.Where(pp =>
                                                                       pp.DistributionPeriod == _.DistributionPeriodCode)
                                 .Select(pp => new ProfilePeriod
                {
                    Occurrence           = pp.Occurrence,
                    Type                 = pp.Type.AsEnum <ProfilePeriodType>(),
                    Year                 = pp.Year,
                    TypeValue            = pp.Period,
                    ProfiledValue        = pp.Value,
                    DistributionPeriodId = _.DistributionPeriodCode
                })
                                 .ToArray()
            }).ToArray();

            foreach (FundingLine fundingLine in batch.FundingLines)
            {
                fundingLine.DistributionPeriods = distributionPeriods.DeepCopy();
            }
        }
        private static void EnsurePublishedProvidersHaveProfilePatternDetails(BatchProfilingResponseModel response,
                                                                              ProfilingBatch batch)
        {
            ProfilePatternKey profilePatternKey = new ProfilePatternKey
            {
                Key             = response.ProfilePatternKey,
                FundingLineCode = batch.FundingLineCode
            };

            foreach (PublishedProviderVersion publishedProviderVersion in batch.PublishedProviders)
            {
                lock (publishedProviderVersion)
                {
                    publishedProviderVersion.SetProfilePatternKey(profilePatternKey.DeepCopy());
                }
            }
        }