Beispiel #1
0
        public async Task Execute(GetCustomerDetailsInput input)
        {
            ICustomer customer = await _customerRepository.Get(input.CustomerId);

            if (customer == null)
            {
                _outputHandler.NotFound($"The customer {input.CustomerId} does not exist or is not processed yet.");
                return;
            }

            List <Boundaries.GetCustomerDetails.Account> accounts = new List <Boundaries.GetCustomerDetails.Account>();

            foreach (Guid accountId in customer.Accounts.GetAccountIds())
            {
                IAccount account = await _accountRepository.Get(accountId);

                if (account != null)
                {
                    Boundaries.GetCustomerDetails.Account accountOutput = new Boundaries.GetCustomerDetails.Account(account);
                    accounts.Add(accountOutput);
                }
            }

            GetCustomerDetailsOutput output = new GetCustomerDetailsOutput(customer, accounts);

            _outputHandler.Default(output);
        }
        public async Task Execute(Input input)
        {
            Guid CustomerId;
            var  result = CommonAccess.GetAccessCustomer(input.CustomerId, _accountRepository, _loginUserService).Result.ToString();

            if (!Guid.TryParse(result, out CustomerId))
            {
                _outputHandler.Error(result);
                return;
            }
            ICustomer customer = await registerUserService.GetCustomer(CustomerId);

            if (customer == null)
            {
                _outputHandler.Error($"The customer {CustomerId} does not exists or is not processed yet.");
                return;
            }

            List <Boundaries.GetCustomerDetails.Account> accounts = new List <Boundaries.GetCustomerDetails.Account>();

            foreach (Guid accountId in customer.Accounts)
            {
                IAccount account = await _accountRepository.Get(accountId);

                if (account != null)
                {
                    Boundaries.GetCustomerDetails.Account accountOutput = new Boundaries.GetCustomerDetails.Account(account);
                    accounts.Add(accountOutput);
                }
            }

            Output output = new Output(customer, accounts);

            _outputHandler.Handle(output);
        }
        /// <summary>
        /// Executes the Use Case.
        /// </summary>
        /// <param name="input">Input Message.</param>
        /// <returns>Task.</returns>
        public async Task Execute(GetCustomerDetailsInput input)
        {
            ICustomer customer;

            if (this.userService.GetCustomerId() is CustomerId customerId)
            {
                try
                {
                    customer = await this.customerRepository.GetBy(customerId)
                               .ConfigureAwait(false);
                }
                catch (CustomerNotFoundException ex)
                {
                    this.outputPort.NotFound(ex.Message);
                    return;
                }
            }
            else
            {
                this.outputPort.NotFound("Customer does not exist.");
                return;
            }

            var accounts = new List <Boundaries.GetCustomerDetails.Account>();

            foreach (AccountId accountId in customer.Accounts.GetAccountIds())
            {
                IAccount account;

                try
                {
                    account = await this.accountRepository.GetAccount(accountId)
                              .ConfigureAwait(false);
                }
                catch (AccountNotFoundException ex)
                {
                    this.outputPort.NotFound(ex.Message);
                    return;
                }

                var outputAccount = new Boundaries.GetCustomerDetails.Account(account);
                accounts.Add(outputAccount);
            }

            this.BuildOutput(
                this.userService.GetExternalUserId(),
                customer,
                accounts);
        }
Beispiel #4
0
        public async Task Execute(GetCustomerDetailsInput input)
        {
            var customer = await _customerRepository.Get(input.CustomerId);

            var accounts = new List <Boundaries.GetCustomerDetails.Account>();

            foreach (Guid accountId in customer.Accounts.GetAccountIds())
            {
                var account = await _accountRepository.Get(accountId);

                var outputAccount = new Boundaries.GetCustomerDetails.Account(account);
                accounts.Add(outputAccount);
            }

            BuildOutput(customer, accounts);
        }
Beispiel #5
0
        public async Task Execute(GetCustomerDetailsInput input)
        {
            ICustomer customer;

            try
            {
                customer = await _customerRepository.Get(input.CustomerId);
            }
            catch (CustomerNotFoundException ex)
            {
                _outputPort.NotFound(ex.Message);
                return;
            }

            var accounts = new List <Boundaries.GetCustomerDetails.Account>();

            foreach (Guid accountId in customer.Accounts.GetAccountIds())
            {
                IAccount account;

                try
                {
                    account = await _accountRepository.Get(accountId);
                }
                catch (AccountNotFoundException ex)
                {
                    _outputPort.NotFound(ex.Message);
                    return;
                }

                var outputAccount = new Boundaries.GetCustomerDetails.Account(account);
                accounts.Add(outputAccount);
            }

            BuildOutput(customer, accounts);
        }