コード例 #1
0
        private void New(CommandLineApplication app)
        {
            app.Command("new", newCmd =>
            {
                newCmd.Description = "To create a new TransactionalAccount";
                newCmd.HelpOption();

                var userArgument        = newCmd.Option("--user-id", "The id of the user who owns the account", CommandOptionType.SingleValue);
                var fiAccountIdArgument = newCmd.Option("--fi-account-id", "The id of the financial instution account id", CommandOptionType.SingleValue);
                userArgument.IsRequired();
                fiAccountIdArgument.IsRequired();
                newCmd.OnExecute(async() =>
                {
                    var trAccount = new TRAccount(userArgument.Value(), "")
                    {
                        Description   = Prompt.GetString("Please enter the description", ""),
                        AccountNumber = Prompt.GetString("Please enter the account number", ""),
                        AccountType   = Enum.Parse <Account.Domain.AccountType>(Prompt.GetString("Please enter the account type")),
                        FinancialInstitutionAccountId = fiAccountIdArgument.Value()
                    };

                    var fiAccount = _repo.GetAsync(fiAccountIdArgument.Value()).Result;
                    fiAccount.AddTransactionalAccount(trAccount);
                    _repo.Add(fiAccount);
                    await _repo.UnitOfWork.SaveEntitiesAsync();
                });
            });
        }
コード例 #2
0
        public async Task <RegisterResult> Handle(RegisterCommand request,
                                                  CancellationToken cancellationToken)
        {
            var account = new FIAccount(request.InternalUserId)
            {
                Description  = request.Description,
                Institution  = request.Institution,
                FriendlyName = request.FriendlyName,
                State        = FIStateEnum.New
            };

            account = _repo.Add(account);
            await _repo.UnitOfWork.SaveEntitiesAsync(cancellationToken);

            return(new RegisterResult(new Results.FinancialInstitutionAccountResult
            {
                Description = account.Description,
                FriendlyName = account.FriendlyName,
                Id = account.Id,
                Institution = account.Institution,
                UserId = account.UserId
            }));
        }