Esempio n. 1
0
        public ContractAllocationCacheModel GetContractAllocation(
            string conRefNum,
            int deliverableCode,
            CancellationToken cancellationToken,
            int?ukPrn = null)
        {
            if (ukPrn == null ||
                ContractAllocations.Any(ca => ca.DeliverableCode == deliverableCode &&
                                        ca.ContractAllocationNumber.CaseInsensitiveEquals(conRefNum)))
            {
                return(ContractAllocations?.FirstOrDefault(ca => ca.DeliverableCode == deliverableCode &&
                                                           ca.ContractAllocationNumber.CaseInsensitiveEquals(conRefNum)));
            }

            PopulateContractAllocations(conRefNum, deliverableCode, cancellationToken, ukPrn);

            return(ContractAllocations?.FirstOrDefault(ca => ca.DeliverableCode == deliverableCode &&
                                                       ca.ContractAllocationNumber.CaseInsensitiveEquals(conRefNum)));
        }
        public ContractAllocationCacheModel GetContractAllocation(
            string conRefNum,
            int deliverableCode,
            CancellationToken cancellationToken,
            long?ukPrn = null)
        {
            if (ukPrn != null && !ContractAllocations
                .Any(ca => ca.DeliverableCode == deliverableCode &&
                     ca.ContractAllocationNumber == conRefNum))
            {
                var contractAllocation =
                    _referenceDataRepository.GetContractAllocation(conRefNum, deliverableCode, cancellationToken, ukPrn);

                if (contractAllocation != null)
                {
                    ContractAllocations.Add(contractAllocation);
                }
            }

            return(ContractAllocations?.FirstOrDefault(ca => ca.DeliverableCode == deliverableCode &&
                                                       ca.ContractAllocationNumber == conRefNum));
        }