/// <summary>
        /// Initializes a new instance of the <see cref="BankLogicService"/> class.
        /// </summary>
        /// <param name="bank"> bank.</param>
        /// <param name="generationIdAccount"> generationIdAccount.</param>
        public BankLogicService(IBank bank, IGenerationIdAccount generationIdAccount)
        {
            if (bank is null)
            {
                throw new ArgumentNullException(nameof(bank));
            }

            if (generationIdAccount is null)
            {
                throw new ArgumentNullException(nameof(generationIdAccount));
            }

            this.generationIdAccount = generationIdAccount;
            this.bank = bank;
        }
Example #2
0
        static void Main(string[] args)
        {
            IBank bank = resolver.Get <IBank>();
            IGenerationIdAccount generationId = resolver.Get <IGenerationIdAccount>();


            BankLogicService bankLogicService = new BankLogicService(bank, generationId);

            //AddBankAccount ##########################################################
            System.Console.WriteLine("AddBankAccount ##########################################################");

            List <IAccountInfo> list = bankLogicService.GetAccounts();

            bankLogicService.AddBankAccount(baseAccount);
            bankLogicService.AddBankAccount(goldAccount);
            bankLogicService.AddBankAccount(goldAccount);

            foreach (var item in bankLogicService.GetAccounts())
            {
                System.Console.WriteLine(item);
            }
            System.Console.WriteLine();

            //Close ##########################################################
            System.Console.WriteLine("Close ##########################################################");

            bankLogicService.Close(list[2]);

            foreach (var item in bankLogicService.GetAccounts())
            {
                System.Console.WriteLine(item);
            }
            System.Console.WriteLine();

            //Deposit ##########################################################
            System.Console.WriteLine("Deposit ##########################################################");

            bankLogicService.Deposit(list[1], 500M);

            foreach (var item in bankLogicService.GetAccounts())
            {
                System.Console.WriteLine(item);
            }
            System.Console.WriteLine();

            //Withdraw ##########################################################
            System.Console.WriteLine("Withdraw ##########################################################");

            bankLogicService.Withdraw(list[1], 100M);

            foreach (var item in bankLogicService.GetAccounts())
            {
                System.Console.WriteLine(item);
            }
            System.Console.WriteLine();

            //WithdrawWithBonuses##########################################################
            System.Console.WriteLine("WithdrawWithBonuses ##########################################################");

            bankLogicService.WithdrawWithBonuses(list[1], 90M, 10M);

            foreach (var item in bankLogicService.GetAccounts())
            {
                System.Console.WriteLine(item);
            }
            System.Console.WriteLine();

            //DB##########################################################
            System.Console.WriteLine("DB ##########################################################");
            list.Clear();

            var tmpList = accountService.GetAll();

            foreach (var item in tmpList)
            {
                list.Add(item);
            }

            foreach (var item in list)
            {
                System.Console.WriteLine(item);
            }
            System.Console.WriteLine();

            System.Console.ReadKey();
        }