public async Task ThenIfTheRemoveOrganisationConfirmCheckHasNotBeenSelectedTheFlashMessageIsPopulatedAndReturned()
        {
            //Act
            var actual = await _orchestrator.RemoveLegalAgreement(new ConfirmLegalAgreementToRemoveViewModel { }, ExpectedUserId);

            //Assert
            Assert.IsNotNull(actual);
            Assert.IsAssignableFrom <OrchestratorResponse <bool> >(actual);
            Assert.IsNotNull(actual.FlashMessage);
            Assert.AreEqual(HttpStatusCode.BadRequest, actual.Status);
        }
        public async Task ThenIfAnInvalidRequestExceptionIsThrownTheOrchestratorResponseContainsTheError()
        {
            //Arrange
            _mediator.Setup(x => x.SendAsync(It.IsAny <RemoveLegalEntityCommand>())).ThrowsAsync(new InvalidRequestException(new Dictionary <string, string>()));

            //Act
            var actual = await _orchestrator.RemoveLegalAgreement(new ConfirmOrganisationToRemoveViewModel(), ExpectedUserId);

            //Assert
            Assert.AreEqual(HttpStatusCode.BadRequest, actual.Status);
        }
        public async Task <ActionResult> RemoveOrganisation(string hashedAccountId, string agreementId, ConfirmLegalAgreementToRemoveViewModel model)

        {
            var response = await _orchestrator.RemoveLegalAgreement(model, OwinWrapper.GetClaimValue(ControllerConstants.UserRefClaimKeyName));

            if (response.Status == HttpStatusCode.OK)
            {
                AddFlashMessageToCookie(response.FlashMessage);

                return(RedirectToAction(ControllerConstants.IndexActionName, new { hashedAccountId }));
            }
            if (response.Status == HttpStatusCode.BadRequest)
            {
                AddFlashMessageToCookie(response.FlashMessage);
                return(RedirectToAction(ControllerConstants.ConfirmRemoveOrganisationActionName, new { hashedAccountId, agreementId }));
            }

            return(RedirectToAction(ControllerConstants.IndexActionName, new { hashedAccountId }));
        }
        public async Task <ActionResult> RemoveOrganisation(ConfirmOrganisationToRemoveViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(ControllerConstants.ConfirmRemoveOrganisationViewName, new OrchestratorResponse <ConfirmOrganisationToRemoveViewModel> {
                    Data = model
                }));
            }
            if (!model.Remove.HasValue || !model.Remove.Value)
            {
                return(RedirectToAction(ControllerConstants.IndexActionName));
            }

            var response = await _orchestrator.RemoveLegalAgreement(model, OwinWrapper.GetClaimValue(ControllerConstants.UserRefClaimKeyName));

            if (response.Status == HttpStatusCode.OK)
            {
                AddFlashMessageToCookie(response.FlashMessage);
                return(RedirectToAction(ControllerConstants.IndexActionName));
            }

            AddFlashMessageToCookie(response.FlashMessage);
            return(View(ControllerConstants.ConfirmRemoveOrganisationViewName, response));
        }