Esempio n. 1
0
        /// <summary>
        /// If all apprenticeships share the same Funding Cap, this is it.
        /// If they have different funding caps, or there is no trainingprogram or apprenticeships,
        /// or there is not enough data to calculate the funding cap for each apprenticeship, this is null
        /// </summary>
        private int?CalculateCommonFundingCap()
        {
            if (TrainingProgramme == null || !Apprenticeships.Any())
            {
                return(null);
            }

            if (!IsLinkedToChangeOfPartyRequest && Apprenticeships.Any(a => !a.StartDate.HasValue))
            {
                return(null);
            }

            int firstFundingCap = IsLinkedToChangeOfPartyRequest
                          ? TrainingProgramme.FundingCapOn(Apprenticeships.First().OriginalStartDate.Value)
                          : TrainingProgramme.FundingCapOn(Apprenticeships.First().StartDate.Value);

            // check for magic 0, which means unable to calculate a funding cap (e.g. date out of bounds)
            if (firstFundingCap == 0)
            {
                return(null);
            }

            if (Apprenticeships.Skip(1).Any(a => TrainingProgramme.FundingCapOn(a.StartDate.Value) != firstFundingCap))
            {
                return(null);
            }

            return(firstFundingCap);
        }
Esempio n. 2
0
        /// <summary>
        /// If all apprenticeships share the same Funding Cap, this is it.
        /// If they have different funding caps, or there is no trainingprogram or apprenticeships,
        /// or there is not enough data to calculate the funding cap for each apprenticeship, this is null
        /// </summary>
        private int?CalculateCommonFundingCap()
        {
            if (TrainingProgramme == null || !Apprenticeships.Any())
            {
                return(null);
            }

            if (Apprenticeships.Any(a => !a.StartDate.HasValue))
            {
                return(null);
            }

            var firstFundingCap = TrainingProgramme.FundingCapOn(Apprenticeships.First().StartDate.Value);

            // check for magic 0, which means unable to calculate a funding cap (e.g. date out of bounds)
            if (firstFundingCap == 0)
            {
                return(null);
            }

            if (Apprenticeships.Skip(1).Any(a => TrainingProgramme.FundingCapOn(a.StartDate.Value) != firstFundingCap))
            {
                return(null);
            }

            return(firstFundingCap);
        }