public void Validate_ChangeStatusType_ShouldBeValidated(ChangeStatusType status) { var model = new ChangeStatusRequestViewModel { SelectedStatusChange = status }; AssertValidationResult(request => request.SelectedStatusChange, model, true); }
public async Task ThenTheCommitmentApiShouldBeCalledWithCorrectStatus(ChangeStatusType type, PaymentStatus expectedStatus) { _validCommand.ChangeType = type; await _handler.Handle(_validCommand); _mockCommitmentApi.Verify(x => x.PatchEmployerApprenticeship( _validCommand.EmployerAccountId, _validCommand.ApprenticeshipId, It.Is <ApprenticeshipSubmission>( y => y.PaymentStatus == expectedStatus && y.LastUpdatedByInfo.Name == _validCommand.UserDisplayName && y.LastUpdatedByInfo.EmailAddress == _validCommand.UserEmailAddress))); }
public async Task ThenIfStoppingSendProviderApprenticeshipStopNotification(ChangeStatusType type, bool expectSendNotification) { //Arrange _validCommand.ChangeType = type; //Act await _handler.Handle(_validCommand); //Assert _providerEmailNotificationService.Verify( x => x.SendProviderApprenticeshipStopNotification(It.IsAny <Apprenticeship>(), It.IsAny <DateTime>()), Times.Exactly(expectSendNotification ? 1 : 0) ); }
private static PaymentStatus DeterminePaymentStatusForChange(ChangeStatusType changeType) { switch (changeType) { case ChangeStatusType.Pause: return(PaymentStatus.Paused); case ChangeStatusType.Resume: return(PaymentStatus.Active); case ChangeStatusType.Stop: return(PaymentStatus.Withdrawn); default: throw new ArgumentOutOfRangeException(nameof(changeType), "Not a valid change type"); } }
private DateTimeViewModel DetermineChangeDate(ChangeStatusType changeType, Apprenticeship apprenticeship, WhenToMakeChangeOptions whenToMakeChange, DateTime?dateOfChange) { if (changeType == ChangeStatusType.Pause || changeType == ChangeStatusType.Resume) { return(new DateTimeViewModel(_currentDateTime.Now.Date)); } if (apprenticeship.IsWaitingToStart(_currentDateTime)) { return(new DateTimeViewModel(apprenticeship.StartDate)); } if (whenToMakeChange == WhenToMakeChangeOptions.Immediately) { return(new DateTimeViewModel(_currentDateTime.Now.Date)); } return(new DateTimeViewModel(dateOfChange)); }
public async Task <OrchestratorResponse <WhenToMakeChangeViewModel> > GetChangeStatusDateOfChangeViewModel( string hashedAccountId, string hashedApprenticeshipId, ChangeStatusType changeType, string externalUserId) { var accountId = _hashingService.DecodeValue(hashedAccountId); var apprenticeshipId = _hashingService.DecodeValue(hashedApprenticeshipId); _logger.Info( $"Determining navigation for type of change status selection. AccountId: {accountId}, ApprenticeshipId: {apprenticeshipId}"); return(await CheckUserAuthorization(async() => { var data = await _mediator.SendAsync(new GetApprenticeshipQueryRequest { AccountId = accountId, ApprenticeshipId = apprenticeshipId }); CheckApprenticeshipStateValidForChange(data.Apprenticeship); return new OrchestratorResponse <WhenToMakeChangeViewModel> { Data = new WhenToMakeChangeViewModel { StartDate = data.Apprenticeship.StartDate.Value, SkipStep = CanChangeDateStepBeSkipped(changeType, data), ChangeStatusViewModel = new ChangeStatusViewModel { ChangeType = changeType } } }; }, hashedAccountId, externalUserId)); }
public async Task <ActionResult> StatusChangeConfirmation(string hashedAccountId, string hashedApprenticeshipId, ChangeStatusType changeType, WhenToMakeChangeOptions whenToMakeChange, DateTime?dateOfChange, bool?madeRedundant) { if (!await IsUserRoleAuthorized(hashedAccountId, Role.Owner, Role.Transactor)) { return(View("AccessDenied")); } var response = await _orchestrator.GetChangeStatusConfirmationViewModel(hashedAccountId, hashedApprenticeshipId, changeType, whenToMakeChange, dateOfChange, madeRedundant, OwinWrapper.GetClaimValue(@"sub")); return(View(response)); }
public async Task <ActionResult> WhenToApplyChange(string hashedAccountId, string hashedApprenticeshipId, ChangeStatusType changeType) { if (!await IsUserRoleAuthorized(hashedAccountId, Role.Owner, Role.Transactor)) { return(View("AccessDenied")); } var response = await _orchestrator.GetChangeStatusDateOfChangeViewModel(hashedAccountId, hashedApprenticeshipId, changeType, OwinWrapper.GetClaimValue(@"sub")); if (response.Data.SkipToMadeRedundantQuestion) { return(RedirectToRoute("MadeRedundant", new { changeType = response.Data.ChangeStatusViewModel.ChangeType.ToString().ToLower(), whenToMakeChange = WhenToMakeChangeOptions.Immediately, dateOfChange = default(DateTime?) })); } if (response.Data.SkipToConfirmationPage) { return(RedirectToRoute("StatusChangeConfirmation", new { changeType = response.Data.ChangeStatusViewModel.ChangeType.ToString().ToLower(), whenToMakeChange = WhenToMakeChangeOptions.Immediately, dateOfChange = default(DateTime?) })); } return(View(new OrchestratorResponse <WhenToMakeChangeViewModel> { Data = response.Data })); }
public async Task <OrchestratorResponse <ConfirmationStateChangeViewModel> > GetChangeStatusConfirmationViewModel(string hashedAccountId, string hashedApprenticeshipId, ChangeStatusType changeType, WhenToMakeChangeOptions whenToMakeChange, DateTime?dateOfChange, string externalUserId) { var accountId = _hashingService.DecodeValue(hashedAccountId); var apprenticeshipId = _hashingService.DecodeValue(hashedApprenticeshipId); _logger.Info( $"Getting Change Status Confirmation ViewModel. AccountId: {accountId}, ApprenticeshipId: {apprenticeshipId}, ChangeType: {changeType}"); return(await CheckUserAuthorization(async() => { var data = await _mediator.SendAsync(new GetApprenticeshipQueryRequest { AccountId = accountId, ApprenticeshipId = apprenticeshipId }); CheckApprenticeshipStateValidForChange(data.Apprenticeship); return new OrchestratorResponse <ConfirmationStateChangeViewModel> { Data = new ConfirmationStateChangeViewModel { ApprenticeName = data.Apprenticeship.ApprenticeshipName, DateOfBirth = data.Apprenticeship.DateOfBirth.Value, ChangeStatusViewModel = new ChangeStatusViewModel { DateOfChange = DetermineChangeDate(changeType, data.Apprenticeship, whenToMakeChange, dateOfChange), ChangeType = changeType, WhenToMakeChange = whenToMakeChange, ChangeConfirmed = false } } }; }, hashedAccountId, externalUserId)); }
private bool CanChangeDateStepBeSkipped(ChangeStatusType changeType, GetApprenticeshipQueryResponse data) { return(data.Apprenticeship.IsWaitingToStart(_currentDateTime) || // Not started (data.Apprenticeship.PaymentStatus == PaymentStatus.Paused && changeType == ChangeStatusType.Resume) || // Resuming (data.Apprenticeship.PaymentStatus == PaymentStatus.Active && changeType == ChangeStatusType.Pause)); // Pausing }