示例#1
0
        private async Task SendUpdates(GetVendorRegistrationCaseStatusUpdateResponse response)
        {
            Task UpdateVendorRegistrationCaseStatus(VendorRegistrationCase @case)
            {
                return(_incentivesService.UpdateVendorRegistrationCaseStatus(
                           new UpdateVendorRegistrationCaseStatusRequest
                {
                    CaseId = @case.CaseId,
                    HashedLegalEntityId = @case.ApprenticeshipLegalEntityId,
                    Status = @case.CaseStatus,
                    CaseStatusLastUpdatedDate = @case.CaseStatusLastUpdatedDate
                }));
            }

            await Task.WhenAll(response.RegistrationCases
                               .Where(c => !string.IsNullOrEmpty(c.ApprenticeshipLegalEntityId) && c.CaseType?.ToUpper() == "NEW")
                               .Select(UpdateVendorRegistrationCaseStatus));
        }
示例#2
0
        public async Task <DateTime> Handle(RefreshVendorRegistrationFormCaseStatusCommand request, CancellationToken cancellationToken)
        {
            var currentDateTime = DateTime.UtcNow;
            var toDateDateTime  = request.FromDateTime.AddDays(1);

            request.ToDateTime = toDateDateTime;

            GetVendorRegistrationCaseStatusUpdateResponse response = null;
            var pageNo = 0;

            do
            {
                pageNo++;
                response = await GetUpdatesFromFinanceApi(request, response?.SkipCode);
                await SendUpdates(response);
            } while (HasNextPage(response) && pageNo < 5);

            var nextRunDateTime = toDateDateTime < currentDateTime ? toDateDateTime : currentDateTime;

            return(await Task.FromResult(nextRunDateTime));
        }
        public async Task Then_The_legal_entities_are_updated_with_the_vendor_registration_form_Details(
            [Frozen] Mock <ICustomerEngagementFinanceService> financeService,
            [Frozen] Mock <IEmployerIncentivesService> incentivesService,
            RefreshVendorRegistrationFormCaseStatusCommandHandler handler,
            GetVendorRegistrationCaseStatusUpdateResponse vendorResponse)
        {
            var command = new RefreshVendorRegistrationFormCaseStatusCommand(DateTime.Now.AddHours(-1));

            financeService.Setup(x => x.GetVendorRegistrationCasesByLastStatusChangeDate(command.FromDateTime, command.FromDateTime.AddDays(1), null))
            .ReturnsAsync(vendorResponse);

            await handler.Handle(command, CancellationToken.None);

            foreach (var @case in vendorResponse.RegistrationCases.Where(x => x.CaseStatus == "NEW"))
            {
                incentivesService.Verify(
                    x => x.UpdateVendorRegistrationCaseStatus(It.Is <UpdateVendorRegistrationCaseStatusRequest>(r =>
                                                                                                                r.CaseId == @case.CaseId &&
                                                                                                                r.HashedLegalEntityId == @case.ApprenticeshipLegalEntityId &&
                                                                                                                r.Status == @case.CaseStatus &&
                                                                                                                r.CaseStatusLastUpdatedDate == @case.CaseStatusLastUpdatedDate)),
                    Times.Once());
            }
        }
示例#4
0
 private static bool HasNextPage(GetVendorRegistrationCaseStatusUpdateResponse response)
 {
     return(response != null && !string.IsNullOrEmpty(response.SkipCode));
 }