public async Task <IActionResult> GetTimetable(string specificationId)
        {
            ApiResponse <SpecificationPublishDateModel> result =
                await _specificationsApiClient.GetPublishDates(specificationId);

            if (result != null)
            {
                return(new OkObjectResult(result));
            }

            return(new NotFoundObjectResult(Content("Error. Not Found.")));
        }
예제 #2
0
        public async Task <PublishedFundingDates> GetDatesForSpecification(string specificationId)
        {
            PublishedFundingDates result;

            ApiResponse <SpecificationPublishDateModel> publishDatesResponse = await _specificationsApiPolicy.ExecuteAsync(() =>
                                                                                                                           _specificationsApiClient.GetPublishDates(specificationId));

            DateTime statusChangedDate            = DateTime.Now;
            DateTime earliestPaymentAvailableDate = DateTime.Now;
            DateTime externalPublicationDate      = DateTime.Now;

            if (publishDatesResponse?.StatusCode != System.Net.HttpStatusCode.OK)
            {
                throw new InvalidOperationException($"Get Publish Dates API returned non success response. Response status code {publishDatesResponse.StatusCode}");
            }

            earliestPaymentAvailableDate =
                publishDatesResponse.Content.EarliestPaymentAvailableDate.HasValue
                ? publishDatesResponse.Content.EarliestPaymentAvailableDate.Value.UtcDateTime
                : DateTime.Now;

            externalPublicationDate =
                publishDatesResponse.Content.ExternalPublicationDate.HasValue
                ? publishDatesResponse.Content.ExternalPublicationDate.Value.UtcDateTime
                : DateTime.Now;

            result = new PublishedFundingDates()
            {
                StatusChangedDate            = statusChangedDate,
                EarliestPaymentAvailableDate = earliestPaymentAvailableDate,
                ExternalPublicationDate      = externalPublicationDate,
            };

            return(result);
        }