public async Task <ActionResult> UndoChanges(long providerId, string hashedApprenticeshipId, UndoApprenticeshipUpdateViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(await UndoChanges(providerId, hashedApprenticeshipId));
            }

            if (viewModel.ConfirmUndo.HasValue && viewModel.ConfirmUndo.Value)
            {
                SetInfoMessage("Changes undone", FlashMessageSeverityLevel.Okay);
                await _orchestrator.SubmitUndoApprenticeshipUpdate(providerId, hashedApprenticeshipId, CurrentUserId, GetSignedInUser());
            }

            return(RedirectToAction("Details", new { providerId, hashedApprenticeshipId }));
        }
示例#2
0
        public async Task ShouldCallMediatorToSubmitUndo(bool isApproved)
        {
            //Arrange
            var providerId       = 1;
            var apprenticeshipId = "appid";
            var userId           = "tester";
            var loginUser        = new SignInUserModel {
                DisplayName = "Bob", Email = "*****@*****.**"
            };

            //Act
            await _orchestrator.SubmitUndoApprenticeshipUpdate(providerId, apprenticeshipId, userId, loginUser);

            //Assert
            _mediator.Verify(x => x.Send(
                                 It.Is <UndoApprenticeshipUpdateCommand>(r =>
                                                                         r.ProviderId == providerId &&
                                                                         r.UserId == userId &&
                                                                         r.UserDisplayName == loginUser.DisplayName &&
                                                                         r.UserEmailAddress == loginUser.Email
                                                                         ), It.IsAny <CancellationToken>()), Times.Once());
        }