Exemplo n.º 1
0
        public async Task <IEnumerable <IncentiveApplication> > Find(WithdrawalCommand withdrawalCommand)
        {
            var applications = await _incentiveApplicationDataRepository.FindApplicationsByAccountLegalEntityAndUln(withdrawalCommand.AccountLegalEntityId, withdrawalCommand.ULN);

            return(from app in applications
                   select _incentiveApplicationFactory.GetExisting(app.Id, app));
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            //Receiver receiver = new Receiver();
            //Command command = new ConcreteCommand(receiver);
            //Invoker invoker = new Invoker();
            //invoker.SetCommand(command);
            //invoker.ExecuteCommand();


            Account account = new Account();

            var commandDepoist = new DepositCommand(account, 5000);

            var invoker = new Bank.Invoker();

            invoker.SetCommand(commandDepoist);
            invoker.ExecuteCommand();

            Console.WriteLine("The current amount of account is:{0}", account.TotalAmount);

            var commandWithdrawal = new WithdrawalCommand(account, 2000);

            invoker.SetCommand(commandWithdrawal);
            invoker.ExecuteCommand();

            Console.WriteLine("The current amount of account is:{0}", account.TotalAmount);

            Console.Read();
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Withdrawal(Guid accountId, [FromBody] WithdrawalModel model, CancellationToken token)
        {
            var command = new WithdrawalCommand {
                AccountId = accountId,
                Amount    = model.Amount,
            };

            var response = await mediator.Send(command, token);

            return(Ok(response));
        }
Exemplo n.º 4
0
        private void ProcessMenu()
        {
            int menuChoice;

            do
            {
                ShowMenu();
                Console.Write("\tSelect an item: ");
                string input = Console.ReadLine();
                if (int.TryParse(input, out menuChoice))
                {
                    switch (menuChoice)
                    {
                    case 0:
                        break;

                    case 1:     // List accounts
                        ListAccounts();
                        break;

                    case 2:     // Show account transactions
                        Console.WriteLine("... tba ...");
                        break;

                    case 3:     // Add account
                        AddAccount();
                        break;

                    case 4:     // Deposit
                    {
                        Console.Write("Index of account: ");
                        int index = int.Parse(Console.ReadLine());
                        var accountReportReadModel = runtime.ServiceLocator.Resolve <AccountReportReadService>();
                        IEnumerable <AccountReadModel> accounts = accountReportReadModel.GetAccounts();
                        Console.Write("Amount to deposit: ");
                        decimal amount = decimal.Parse(Console.ReadLine());
                        var     cmd    = new DepositCommand {
                            Amount = amount, Id = accounts.ToArray()[index].Id
                        };
                        commandBus.Send(cmd);
                    }
                    break;

                    case 5:     // Withdrawal
                    {
                        Console.Write("Index of account: ");
                        int index = int.Parse(Console.ReadLine());
                        var accountReportReadModel = runtime.ServiceLocator.Resolve <AccountReportReadService>();
                        IEnumerable <AccountReadModel> accounts = accountReportReadModel.GetAccounts();
                        Console.Write("Amount to withdraw: ");
                        decimal amount = decimal.Parse(Console.ReadLine());
                        var     cmd    = new WithdrawalCommand {
                            Amount = amount, Id = accounts.ToArray()[index].Id
                        };
                        commandBus.Send(cmd);
                    }
                    break;

                    default:
                        Console.WriteLine("~ Invalid entry ~");
                        break;
                    }
                }
            } while (menuChoice != 0);
        }