public void Arrange()
        {
            _validator = new Mock <IValidator <UpdateOrganisationDetailsCommand> >();
            _validator.Setup(x => x.Validate(It.IsAny <UpdateOrganisationDetailsCommand>())).Returns(new ValidationResult());

            _hashingService = new Mock <IHashingService>();
            _hashingService.Setup(x => x.DecodeValue(HashedAccountId)).Returns(AccountId);

            _accountRepository = new Mock <IAccountRepository>();

            _membershipRepository = new Mock <IMembershipRepository>();
            _membershipRepository
            .Setup(mr => mr.GetCaller(AccountId, _expectedUserId))
            .Returns <long, string>((accountId, userRef) => Task.FromResult(new MembershipView {
                AccountId = AccountId, FirstName = "Harry", LastName = "Potter"
            }));

            _eventPublisher = new Mock <IEventPublisher>();

            _command = new UpdateOrganisationDetailsCommand {
                AccountLegalEntityId = ExpectedAccountLegalEntityId, Name = ExpectedOrganisationName, Address = ExpectedOrganisationAddress, HashedAccountId = HashedAccountId, UserId = _expectedUserId
            };

            _handler = new UpdateOrganisationDetailsCommandHandler(
                _validator.Object,
                _accountRepository.Object,
                _membershipRepository.Object,
                _hashingService.Object,
                _eventPublisher.Object);
        }
Exemple #2
0
        public async Task <OrchestratorResponse <OrganisationUpdatedNextStepsViewModel> > UpdateOrganisation(
            string accountLegalEntityPublicHashedId,
            string organisationName,
            string organisationAddress,
            string hashedAccountId,
            string userId)
        {
            var result = new OrchestratorResponse <OrganisationUpdatedNextStepsViewModel>
            {
                Data = new OrganisationUpdatedNextStepsViewModel()
            };

            try
            {
                var request = new UpdateOrganisationDetailsCommand
                {
                    AccountLegalEntityId = _accountLegalEntityHashingService.DecodeValue(accountLegalEntityPublicHashedId),
                    Name            = organisationName,
                    Address         = organisationAddress,
                    HashedAccountId = hashedAccountId,
                    UserId          = userId
                };

                await _mediator.SendAsync(request);
            }
            catch (Exception)
            {
                result.Data.ErrorMessage = "Failed to update the organisation's details.";
            }

            return(result);
        }