コード例 #1
0
 public TransactionStatus MakeDeposit(decimal amount, DateTime date, string note)
 {
     if (!TranscationChecker.IsAmountValid(amount))
     {
         return(new TransactionStatus(Number, Owner, TransactionStatusCode.FAILED, DateTime.Now, "Amount of deposit is not valid"));
     }
     return(_MakeDeposit(amount, date, note));
 }
コード例 #2
0
 public TransactionStatus MakeWithdrawal(decimal amount, DateTime date, string note)
 {
     if (!TranscationChecker.IsAmountValid(amount))
     {
         return(new TransactionStatus(Number, Owner, TransactionStatusCode.FAILED, DateTime.Now, "Amount of withdrawal is not valid"));
     }
     if (!TranscationChecker.IsFundSufficientForWithdrawal(amount, this))
     {
         return(new TransactionStatus(Number, Owner, TransactionStatusCode.FAILED, DateTime.Now, "Not sufficient fund for this withdrawal"));
     }
     return(_MakeWithdrawal(amount, date, note));
 }
コード例 #3
0
        public BankAccount(string name, string password, decimal initialBalance = 0M)
        {
            Password = password;
            Owner    = name;
            if (!TranscationChecker.IsInitialDepositValid(initialBalance))
            {
                throw new ArgumentOutOfRangeException(nameof(initialBalance), "Cannot open account");
            }
            Number = (AccountNumberSeed++).ToString();
            var firstTransaction = new Transaction(Number, Owner, initialBalance, DateTime.Now, "Opens account");

            AllTransactions.Add(firstTransaction);
            Serialize.WriteBankAccount(this);
            Serialize.WriteTransaction(this, firstTransaction);
        }