예제 #1
0
        public BankTransactionState PutMoney(Money amount)
        {
            if (SessionAccount == null)
            {
                return(BankTransactionState.NotLoggedIn);
            }

            var transaction = new CashTransaction(amount, SessionAccount.Iban, "bar deposit");

            var receiver = BankStorage.GetAccount(SessionAccount.Iban);

            receiver.Transfer(transaction);

            BankStorage.AddAccount(receiver);

            SaveSession();

            return(BankTransactionState.Success);
        }
예제 #2
0
        public BankTransactionState TransferMoney(Money amount, IBAN to, string referenceText)
        {
            if (SessionAccount == null)
            {
                return(BankTransactionState.NotLoggedIn);
            }

            var transaction = new Transaction(amount, SessionAccount.Iban, to, referenceText);

            var receiver = BankStorage.GetAccount(to);

            SessionAccount.Transfer(transaction);
            receiver.Transfer(transaction);

            BankStorage.AddTransaction(transaction);
            BankStorage.AddAccount(receiver);

            SaveSession();

            return(BankTransactionState.Success);
        }
예제 #3
0
        public IBAN CreateBankAccount(Person accountHolder, string accountName, string password, Money?startingCredit)
        {
            var bankAccount = new BankAccount(accountHolder, accountName, password);

            if (DateTime.Now - accountHolder.BirthDate < new TimeSpan(days: 16 * 365, hours: 0, minutes: 0, seconds: 0))
            {
                // Student Bonus of 50€ if AccountHolder younger than 16
                var transaction = new CashTransaction(new Money(50, CurrencyCode.EUR), bankAccount.Iban, "Youth Bonus");
                bankAccount.Transfer(transaction);
            }

            if (startingCredit.HasValue)
            {
                var transaction = new CashTransaction(startingCredit.Value, bankAccount.Iban, "Starting credit");
                bankAccount.Transfer(transaction);
            }

            SessionAccount = bankAccount;

            BankStorage.AddAccount(bankAccount);

            return(bankAccount.Iban);
        }
예제 #4
0
 private void SaveSession() => BankStorage.AddAccount(SessionAccount);