public async Task <ActionResult> RemovePaye(string hashedAccountId, RemovePayeSchemeViewModel model)
        {
            model.UserId = OwinWrapper.GetClaimValue(ControllerConstants.UserRefClaimKeyName);

            if (model.RemoveScheme == 1)
            {
                return(RedirectToAction(ControllerConstants.IndexActionName, ControllerConstants.EmployerAccountPayeControllerName, new { model.HashedAccountId }));
            }

            var result = await _employerAccountPayeOrchestrator.RemoveSchemeFromAccount(model);

            if (result.Status != HttpStatusCode.OK)
            {
                return(View(ControllerConstants.RemoveViewName, result));
            }

            model.PayeSchemeName = model.PayeSchemeName ?? string.Empty;

            var flashMessage = new FlashMessageViewModel
            {
                Severity   = FlashMessageSeverityLevel.Success,
                Headline   = $"You've removed {model.PayeRef}",
                SubMessage = model.PayeSchemeName,
                HiddenFlashMessageInformation = "page-paye-scheme-deleted"
            };

            AddFlashMessageToCookie(flashMessage);

            return(RedirectToAction(ControllerConstants.IndexActionName, ControllerConstants.EmployerAccountPayeControllerName, new { model.HashedAccountId }));
        }
Пример #2
0
        public async Task <ActionResult> RemovePaye(string hashedAccountId, RemovePayeSchemeViewModel model)
        {
            model.UserId = OwinWrapper.GetClaimValue("sub");

            if (model.RemoveScheme == 1)
            {
                return(RedirectToAction("Index", "EmployerAccountPaye", new { model.HashedAccountId }));
            }

            var result = await _employerAccountPayeOrchestrator.RemoveSchemeFromAccount(model);

            if (result.Status != HttpStatusCode.OK)
            {
                return(View("Remove", result));
            }

            var flashMessage = new FlashMessageViewModel
            {
                Severity = FlashMessageSeverityLevel.Success,
                Headline = $"You've removed {model.PayeRef}",
                HiddenFlashMessageInformation = "page-paye-scheme-deleted"
            };

            AddFlashMessageToCookie(flashMessage);

            return(RedirectToAction("Index", "EmployerAccountPaye", new { model.HashedAccountId }));
        }
        public async Task ThenTheCommandIsCalledForRemovingThePayeScheme()
        {
            //Arrange
            var hashedId = "ABV465";
            var userRef  = "abv345";
            var payeRef  = "123/abc";
            var model    = new RemovePayeSchemeViewModel {
                HashedAccountId = hashedId, PayeRef = payeRef, UserId = userRef
            };

            //Act
            var actual = await _employerAccountPayeOrchestrator.RemoveSchemeFromAccount(model);

            //Assert
            _mediator.Verify(x => x.SendAsync(It.Is <RemovePayeFromAccountCommand>(c => c.HashedAccountId.Equals(hashedId) && c.PayeRef.Equals(payeRef) && c.UserId.Equals(userRef))), Times.Once);
        }