Exemplo n.º 1
0
        public void AddOrUpdateCustomProfile(string fundingLineCode,
                                             decimal?carryOver,
                                             string distributionPeriodId)
        {
            DistributionPeriod distributionPeriod = GetDistributionPeriod(fundingLineCode, distributionPeriodId);

            CustomProfiles ??= new List <FundingLineProfileOverrides>();

            FundingLineProfileOverrides customProfile = CustomProfiles.SingleOrDefault(_ =>
                                                                                       _.FundingLineCode == fundingLineCode) ?? new FundingLineProfileOverrides();

            customProfile.FundingLineCode = fundingLineCode;
            customProfile.CarryOver       = carryOver;
            customProfile.DistributionPeriods ??= new List <DistributionPeriod>();

            DistributionPeriod existingDistributionPeriod = customProfile.DistributionPeriods
                                                            .SingleOrDefault(_ => _.DistributionPeriodId == distributionPeriod.DistributionPeriodId);

            if (existingDistributionPeriod == null)
            {
                customProfile.DistributionPeriods = customProfile.DistributionPeriods.Concat(new[]
                {
                    distributionPeriod
                });
                CustomProfiles = CustomProfiles.Concat(new[]
                {
                    customProfile
                });
            }
            else
            {
                existingDistributionPeriod.Value          = distributionPeriod.Value;
                existingDistributionPeriod.ProfilePeriods = distributionPeriod.ProfilePeriods.DeepCopy();
            }
        }
Exemplo n.º 2
0
 public bool FundingLineHasCustomProfile(string fundingLineCode)
 => CustomProfiles?.Any(_ => _.FundingLineCode == fundingLineCode) == true;