Beispiel #1
0
        public async Task <IActionResult> GetFundingStreamPaymentDates(string fundingStreamId, string fundingPeriodId)
        {
            Guard.IsNullOrWhiteSpace(fundingStreamId, nameof(fundingStreamId));
            Guard.IsNullOrWhiteSpace(fundingPeriodId, nameof(fundingPeriodId));

            FundingStreamPaymentDates fundingStreamPaymentDates = await _resilience.ExecuteAsync(() =>
                                                                                                 _fundingStreamPaymentDates.GetUpdateDates(fundingStreamId, fundingPeriodId));

            return(fundingStreamPaymentDates == null ? (IActionResult) new NotFoundResult() :
                   new OkObjectResult(fundingStreamPaymentDates));
        }
Beispiel #2
0
        public async Task <IActionResult> GetProfileHistory(string fundingStreamId,
                                                            string fundingPeriodId,
                                                            string providerId)
        {
            Guard.IsNullOrWhiteSpace(providerId, nameof(providerId));
            Guard.IsNullOrWhiteSpace(fundingPeriodId, nameof(fundingPeriodId));
            Guard.IsNullOrWhiteSpace(fundingStreamId, nameof(fundingStreamId));

            FundingStreamPaymentDates paymentDates = await _paymentDatesPolicy.ExecuteAsync(()
                                                                                            => _paymentDates.GetUpdateDates(fundingStreamId, fundingPeriodId));

            PublishedProviderVersion publishedProviderVersion = await _publishedFundingPolicy.ExecuteAsync(()
                                                                                                           => _publishedFunding.GetLatestPublishedProviderVersion(fundingStreamId, fundingPeriodId, providerId));

            if (publishedProviderVersion == null)
            {
                return(new NotFoundResult());
            }

            ProfileTotal[] publishedProviderProfiling = new PaymentFundingLineProfileTotals(publishedProviderVersion)
                                                        .ToArray();

            foreach (FundingStreamPaymentDate paymentDate in PastPaymentDates(paymentDates))
            {
                ProfileTotal matchingProfileTotal = publishedProviderProfiling.SingleOrDefault(_ => _.Year == paymentDate.Year &&
                                                                                               _.TypeValue == paymentDate.TypeValue &&
                                                                                               _.Occurrence == paymentDate.Occurrence);

                if (matchingProfileTotal == null)
                {
                    continue;
                }

                matchingProfileTotal.IsPaid = true;
            }

            return(new OkObjectResult(publishedProviderProfiling));
        }