static void Main(string[] args)
    {
        /*
           *      Account Class Test
           */
          Console.WriteLine("**********     Account Class Test     **********");
          Console.WriteLine("");

          // Create new account
          decimal openningAmount = 65.12M;
          Account account = new Account(openningAmount);

          // Display openning balance
          Console.WriteLine("Openning balance for account is {0:C}", account.Balance);
          Console.WriteLine("");

          // Test withdraw amount exceeds balance
          decimal excessWithdraw = 1000M;
          account.Debit(excessWithdraw);
          Console.WriteLine("Try to withdraw {0:C} from account. Unchanged balance is {1:C}",
         excessWithdraw, account.Balance);
          Console.WriteLine("");

          // Test a proper withdraw amount
          decimal properWithdraw = 5.12M;
          account.Debit(properWithdraw);
          Console.WriteLine("Withdraw {0:C} from account. New balance is {1:C}", properWithdraw, account.Balance);
          Console.WriteLine("");

          // Test deposit into account
          decimal deposit = 0.01M;
          account.Credit(deposit);
          Console.WriteLine("Deposit {0:C} into account. New balance is {1:C}", deposit, account.Balance);
          Console.WriteLine("");

          // Test creating account with a negative openning balance
          openningAmount = -10M;
          Console.WriteLine("Try to create new account with {0:C}", openningAmount);
          try
          {
         Account negative = new Account(openningAmount);
          }
          catch (ArgumentOutOfRangeException e)
          {
         Console.WriteLine(e.Message);
          }
          finally
          {
         Console.WriteLine("");
          }

          /*
           *      SavingAccount Class Test
           */
          Console.WriteLine("");
          Console.WriteLine("**********     SavingAccount Class Test     **********");
          Console.WriteLine("");

          // Create new Saving Account
          decimal interestRate = 0.05M;
          openningAmount = 800M;
          SavingsAccount savingsAccount = new SavingsAccount(openningAmount, interestRate);

          // Display openning balance
          Console.WriteLine("Openning balance for savings account is {0:C}", savingsAccount.Balance);
          Console.WriteLine("Having an interest rate of {0:P}", savingsAccount.InterestRate);
          Console.WriteLine("");

          // Test deposit into account (from Account Class)
          deposit = 100M;
          savingsAccount.Credit(deposit);
          Console.WriteLine("Deposit {0:C} into savings account. New balance is {1:C}",
         deposit, savingsAccount.Balance);
          Console.WriteLine("");

          // Test calculate interest
          decimal interestAmount = savingsAccount.CalculateInterest();
          Console.WriteLine("Calculated amount from {0:P} interest is {1:C}", interestRate ,interestAmount);
          Console.WriteLine("");

          /*
           *      CheckingAccount Class Test
           */
          Console.WriteLine("");
          Console.WriteLine("**********     CheckingAccount Class Test     **********");
          Console.WriteLine("");

          // Create new Checking Account
          decimal transactionFee = 0.02M;
          openningAmount = 500M;
          CheckingAccount checkingAccount = new CheckingAccount(openningAmount, transactionFee);

          // Display openning balance
          Console.WriteLine("Openning balance for checking account is {0:C}", checkingAccount.Balance);
          Console.WriteLine("Having a transaction fee of {0:C}", checkingAccount.TransactionFee);
          Console.WriteLine("");

          // Test deposit into checking account (overrides Account Class)
          deposit = 100M;
          checkingAccount.Credit(deposit);
          Console.WriteLine("Deposit {0:C} into checking account. New balance is {1:C}",
         deposit, checkingAccount.Balance);
          Console.WriteLine("");

          // Test excess withdraw from checking account
          excessWithdraw = 1000M;
          checkingAccount.Debit(excessWithdraw);
          Console.WriteLine("Try to withdraw {0:C} from checking account. Unchanged balance is {1:C}",
         excessWithdraw, checkingAccount.Balance);
          Console.WriteLine("");

          // Test a proper withdraw amount from checking account
          properWithdraw = 99M;
          checkingAccount.Debit(properWithdraw);
          Console.WriteLine("Withdraw {0:C} from checking account. New balance is {1:C}",
         properWithdraw, checkingAccount.Balance);
          Console.WriteLine("");

          // Freeze console window
          Console.ReadLine();
    }
示例#2
0
        public static void EncapsulationDemo()
        {
            BankAccountPublic bankAcctPub = new BankAccountPublic();

            // call a public method
            decimal amount = bankAcctPub.GetAmount();

            Console.WriteLine("Bank Account Amount: " + amount);

            BankAccountProtected[] bankAccts = new BankAccountProtected[2];
            bankAccts[0] = new SavingsAccount();
            bankAccts[1] = new CheckingAccount();

            foreach (BankAccountProtected acct in bankAccts)
            {
                // call public method, which invokes protected virtual methods
                acct.CloseAccount();
            }

            BankAccountExternal BankAcctExt = new BankAccountExternal();

            // call a public method
            amount = BankAcctExt.GetAmount();

            Console.WriteLine("External Bank Account Amount: " + amount);
        }
    public void WithdrawRemovesMoney()
    {
        IAccount account = new SavingsAccount(36241604394L, 100.0, new Customer());
        service.Withdraw(account, 50.0);

        Assert.AreEqual(50.0, account.GetAmount());
    }
    public void DepositAddsMoney()
    {
        IAccount account = new SavingsAccount(36241604394L, 100.0, new Customer());
        service.Deposit(account, 100.0);

        Assert.AreEqual(200.0, account.GetAmount());
    }
    public void SavingsAbleToWithDraw()
    {
        SavingsAccount ca = new SavingsAccount(2000);
            ca.WithDrawMoney(1000);

            Assert.AreEqual(950, ca.Balance);
    }
    public void SavingsAbleToDeposit()
    {
        SavingsAccount ca = new SavingsAccount(0);
            ca.DepositMoney(1000);

            Assert.AreEqual(1000, ca.Balance);
    }
        public void testApp()
        {
            CheckingAccount checkingAccount = new CheckingAccount();
            SavingsAccount savingsAccount = new  SavingsAccount();

            Customer henry = new Customer("Henry").OpenAccount(checkingAccount).OpenAccount(savingsAccount);

            checkingAccount.deposit(300.0);
            savingsAccount.deposit(4000.0);
            savingsAccount.withdraw(200.0);
            henry.TransferFunds(checkingAccount, savingsAccount, 200.00);
            henry.GetStatement();

            //Assert.AreEqual("Statement for Henry" + Environment.NewLine+
            //                "Checking Account"+
            //                "  deposit $300.00" +  Environment.NewLine+
            //                "  withdrawal $200.00" +      Environment.NewLine+
            //                "Total $100.00" +  Environment.NewLine+
            //                "Saving Account" +
            //                "  deposit $4,000.00" + Environment.NewLine +
            //                "  withdrawal $200.00" + Environment.NewLine +
            //                "  deposit $200.00" + Environment.NewLine +
            //                "Total $4,000.00" + Environment.NewLine +
            //                "Total In All Accounts $4,100.00", henry.GetStatement());
            Assert.AreEqual("$4,100.00", henry.GetStatement());
        }
示例#8
0
        public void TestApp()
        {
            CheckingAccount checkingAccount = new CheckingAccount();
            SavingsAccount savingsAccount = new SavingsAccount();

            Customer henry = new Customer("Henry").OpenAccount(checkingAccount).OpenAccount(savingsAccount);

            checkingAccount.Deposit(100.0m);
            savingsAccount.Deposit(4000.0m);
            savingsAccount.Withdraw(200.0m);

            var actual = henry.GetStatement();
            var expected = "Statement for HENRY" + Environment.NewLine +
                    Environment.NewLine +
                    "Checking Account" + Environment.NewLine +
                    "  deposit $100.00" + Environment.NewLine +
                    "Total $100.00" + Environment.NewLine +
                    Environment.NewLine +
                    "Savings Account" + Environment.NewLine +
                    "  deposit $4,000.00" + Environment.NewLine +
                    "  withdrawal $200.00" + Environment.NewLine +
                    "Total $3,800.00" + Environment.NewLine +
                    Environment.NewLine +
                    "Total In All Accounts: $3,900.00";

            Assert.AreEqual(expected, actual);
        }
        public void NewAccountShouldBeCorrect()
        {
            var account = new SavingsAccount(ValidAccountNumber, 100.0, customer);

            Assert.AreEqual(36241604394L, account.GetAccountNumber());
            Assert.AreEqual(100.0, account.GetAmount());
            Assert.AreSame(customer, account.GetAccountOwner());
        }
        public void ShouldAccountNegativeDeposit()
        {
            //Arrange
            var sut = new SavingsAccount("Raghav", "A1234567", 2000);

            //Act
            decimal resultBalance = sut.Deposit(-1000);
        }
    public void SavingsNotAllowedToOverDraw()
    {
        SavingsAccount ca = new SavingsAccount(100);
            bool result = ca.WithDrawMoney(1000);

            Assert.IsFalse(result);
            Assert.AreEqual(100, ca.Balance);
    }
示例#12
0
 static void Main(string[] args)
 {
     IAccountsInterface HenryChecking = new CheckingAccount();
     IAccountsInterface HenrySavings = new SavingsAccount();
     //IAccountsInterface HenryMaxiSavings = new MaxiSavingsAccount();
     ICustomerInterface Henry = new Customers("Henry");
     Henry.AddAccount(HenryChecking);
     Henry.AddAccount(HenrySavings);
     //Henry.AddAccount(HenryMaxiSavings);
     //Henry.Deposit(HenryChecking, 100.00);
     //Henry.Deposit(HenryChecking, 225.00);
     //Henry.Deposit(HenrySavings, 1550.00);
     //Henry.Withdraw(HenrySavings, 225.00);
     //Henry.Deposit(HenrySavings, 1225.00);
     //Henry.Withdraw(HenrySavings, 1225.00);
     //Henry.Deposit(HenryMaxiSavings, 1747.00);
     //Henry.Deposit(HenryMaxiSavings, 2750.00);
     //Henry.Transfer(HenrySavings, HenryChecking, 1250);
     Henry.Deposit(HenryChecking, 100.00);
     Henry.Deposit(HenryChecking, 225.00);
     Henry.Deposit(HenryChecking, 1750.00);
     Henry.Deposit(HenrySavings, 1550.00);
     Henry.Deposit(HenrySavings, 1225.00);
     Henry.Transfer(HenrySavings, HenryChecking, 1125.00);
     String HenryAccountStatement = Henry.GetAccountStatementforCustomer();
     IAccountsInterface JohnChecking = new CheckingAccount();
     IAccountsInterface JohnMaxiSavings = new MaxiSavingsAccount();
     ICustomerInterface John = new Customers("John");
     John.AddAccount(JohnChecking);
     John.AddAccount(JohnMaxiSavings);
     John.Deposit(JohnChecking, 1000.00);
     John.Deposit(JohnChecking, 1100.00);
     John.Withdraw(JohnChecking, 203.20);
     John.Withdraw(JohnChecking, 200.00);
     John.Deposit(JohnMaxiSavings, 1747.00);
     John.Deposit(JohnMaxiSavings, 27050.00);
     String JohnAccountStatement = John.GetAccountStatementforCustomer();
     IAccountsInterface JamesChecking = new CheckingAccount();
     IAccountsInterface JamesSavings = new SavingsAccount();
     IAccountsInterface JamesMaxiSavings = new MaxiSavingsAccount();
     ICustomerInterface James = new Customers("James");
     James.AddAccount(JamesChecking);
     James.AddAccount(JamesSavings);
     James.AddAccount(JamesMaxiSavings);
     James.Deposit(JamesChecking, 2679.72);
     James.Withdraw(JamesChecking, 500.00);
     James.Deposit(JamesSavings, 15000.00);
     James.Deposit(JamesMaxiSavings, 22500.00);
     James.Deposit(JamesMaxiSavings, 17000.00);
     James.Withdraw(JamesMaxiSavings, 20000.00);
     String JamesAccountStatement = James.GetAccountStatementforCustomer();
     MainBank bank = new MainBank();
     bank.AddCustomer(Henry);
     bank.AddCustomer(John);
     bank.AddCustomer(James);
     String CustomerSummary = bank.CustomerSummary();
     String InterestSummary = bank.InterestSummary();
 }
    public void SavingsAbleToTransferFunds()
    {
        SavingsAccount ca = new SavingsAccount(1200);
            SavingsAccount ca2 = new SavingsAccount(0);
            ca.TransferMoney(ca2, 1000);

            Assert.AreEqual(100, ca.Balance);
            Assert.AreEqual(1000, ca2.Balance);
    }
示例#14
0
        public void SavingsAccountTest_InterestEarned_More_Than_A_Thousand()
        {
            IAccount savingsAccount = new SavingsAccount();

            savingsAccount.Deposit(1200);
            var actual = savingsAccount.InterestEarned();

            Assert.AreEqual(1.4m, actual);
        }
示例#15
0
        public void SavingsAccountTest_InterestEarned_Less_Than_A_Thousand()
        {
            IAccount savingsAccount = new SavingsAccount();

            savingsAccount.Deposit(450.75m);
            savingsAccount.Deposit(120.50m);
            savingsAccount.Withdraw(4.60m);

            Assert.AreEqual(.56665m, savingsAccount.InterestEarned());
        }
示例#16
0
        public void SavingsAccount()
        {
            Bank bank = new Bank();
            SavingsAccount savingsAccount = new SavingsAccount();
            bank.AddCustomer(new Customer("Bill").OpenAccount(savingsAccount));

            savingsAccount.Deposit(1500.0m);

            Assert.AreEqual(2.0m, bank.totalInterestPaid());
        }
 public static void Main()
 {
     SavingsAccount s =  new SavingsAccount(500.00, 4.5);
     s.Deposit(135.22);
     s.PostInterest();
     s.Withdraw(50);
     Console.WriteLine
      ("The balance of SavingsAccount s is {0:C}",
                                   s.GetBalance());
 }
示例#18
0
        public void SavingAccountTest_SumTransactions()
        {
            IAccount savingsAccount = new SavingsAccount();

            savingsAccount.Deposit(450.75m);
            savingsAccount.Deposit(120.32m);
            savingsAccount.Withdraw(4.67m);

            Assert.AreEqual(566.40m, savingsAccount.SumTransactions());
        }
示例#19
0
        public void savings_account()
        {
            Bank bank = new Bank();
            SavingsAccount savingAccount = new SavingsAccount();
            bank.addCustomer(new Customer("Bill").OpenAccount(savingAccount));

            savingAccount.deposit(1500.0);

            Assert.AreEqual(2.0, bank.totalInterestPaid(), DOUBLE_DELTA);
        }
        public void ShouldAccountPostiveDeposit()
        {
            //Arrange
            var sut = new SavingsAccount("Raghav", "A1234567", 2000);

            //Act
            decimal resultBalance = sut.Deposit(1000);

            //Assert
            Assert.That(resultBalance, Is.GreaterThan(2000));
        }
示例#21
0
 public static void Main()
 {
     BankAccount b1 = new CheckingAccount(1500.00,.50);
     BankAccount b2 = new SavingsAccount(500.00, 4.0);
     b1.Deposit(400.00);
     b1.Withdraw(50.00);
     Console.WriteLine
       ("The balance of the BankAccount to which b1 refers is {0:C}",
                                           b1.GetBalance());
     b2.Withdraw(50.00);
     Console.WriteLine
       ("The balance of the BankAccount to which b2 refers is {0:C}",
                                           b2.GetBalance());
     b2 = b1;
     b2.Withdraw(50.00);
     Console.WriteLine
       ("The balance of the BankAccount to which b2 refers is {0:C}",
                                           b2.GetBalance());
 }
示例#22
0
        static void Main(string[] args)
        {
            Account         acc  = new Account(8020, "Francisco", 100.00);
            BusinessAccount bacc = new BusinessAccount(1022, "Maria", 200.00, 300.00);


            //UPCASTING

            Account acc1 = bacc;
            Account acc2 = new BusinessAccount(1003, "Bob", 400, 500.00);
            Account acc3 = new BusinessAccount(200, "Joao", 500, 600);


            //DOWNCASTING

            BusinessAccount acc4 = (BusinessAccount)acc2;

            acc4.Loan(100.00);

            //BusinessAccount acc5 = (BusinessAccount)acc3;
            if (acc3 is BusinessAccount)
            {
                // BusinessAccount acc5 = (BusinessAccount)acc3;
                BusinessAccount acc5 = acc3 as BusinessAccount;
                acc5.Loan(600);
                Console.WriteLine("Loan!");
            }

            if (acc3 is SavingsAccount)
            {
                // SavingsAccount acc5 = (SavingsAccount)acc3;
                SavingsAccount acc5 = acc3 as SavingsAccount;
                acc5.UpdateBalance();
                Console.WriteLine("Update!");
            }
        }
 public void Annual_balance_update_for_small_negative_start_balance()
 {
     Assert.Equal(-0.12695199m, SavingsAccount.AnnualBalanceUpdate(-0.123m));
 }
 public Transfer(SavingsAccount acct1, CheckingAccount acct2, Money m)
 {
 }
 public void Annual_balance_update_for_huge_positive_start_balance()
 {
     Assert.Equal(920352587.26744292868451875m, SavingsAccount.AnnualBalanceUpdate(898124017.826243404425m));
 }
 public void Regular_negative_interest_rate()
 {
     Assert.Equal(-3.213f, SavingsAccount.InterestRate(-300.0m));
 }
 public void Interest_on_negative_balance()
 {
     Assert.Equal(-321.3m, SavingsAccount.Interest(-10000.0m));
 }
 public void Maximum_first_interest_rate()
 {
     Assert.Equal(0.5f, SavingsAccount.InterestRate(999.9999m));
 }
 public void Minimal_negative_interest_rate()
 {
     Assert.Equal(-3.213f, SavingsAccount.InterestRate(-0.000001m));
 }
示例#30
0
    public static void Main()
    {
        SavingsAccount oSavingsAccount = new SavingsAccount();
        double balance;
        balance = oSavingsAccount.Withdraw(2, 500);
        Console.WriteLine("balance after withdrawal: " + balance);

        InterestBearingCheckingAccount oIntBrCkAct = new InterestBearingCheckingAccount();
        oIntBrCkAct.Withdraw(500);
        oIntBrCkAct.HideMe();

        CheckingAccount oCheckingAccount = new CheckingAccount();
        oCheckingAccount.Peek();
        oCheckingAccount.Peek(77);

        List<Account> AccountList = new List<Account>();
        AccountList.Add(oSavingsAccount);
        AccountList.Add(oIntBrCkAct);
        AccountList.Add(oCheckingAccount);

        Console.WriteLine("iterate Accounts for info:");
        foreach (var a in AccountList)
        {
            Console.WriteLine("acct info: " + a.GetAccountInfo());
        }

        XCheckingAccount xChkAct = new XCheckingAccount();
        string info = xChkAct.GetAccountInfo();
        Console.WriteLine("X chk acct info: " + info);
        XSavingsAccount xSvgAct = new XSavingsAccount();

        List<IAccount> IAccountList = new List<IAccount>();
        IAccountList.Add(xChkAct);
        IAccountList.Add(xSvgAct);

        Console.WriteLine("iterate IAccounts for info:");
        foreach (var a in IAccountList)
        {
            Console.WriteLine("iacct info: " + a.GetAccountInfo());
        }
    }
 public void Interest_on_small_balance()
 {
     Assert.Equal(2.77775m, SavingsAccount.Interest(555.55m));
 }
示例#32
0
        public ActionResult AdjustDispute(int?id)
        {
            Transaction transaction = db.Transactions.Find(id);

            if (transaction.CheckingAccountAffected != null)
            {
                EmailMessaging.SendEmail(transaction.CheckingAccountAffected.Customer.Email, "Dispute Adjusted", "The manager has adjusted your dispute. ");
                if (transaction.TransactionType == "Withdrawal" || transaction.TransactionType == "Bill Payment" || transaction.TransactionType == "Fee")
                {
                    transaction.CheckingAccountAffected.Balance += transaction.Amount;
                    transaction.CheckingAccountAffected.Balance -= transaction.Dispute.CorrectAmount;
                    transaction.Amount = transaction.Dispute.CorrectAmount;
                    transaction.Dispute.CurrentStatus = "Accepted";
                    db.SaveChanges();
                    return(RedirectToAction("ResolveDisputeConfirmation"));
                }
                else if (transaction.TransactionType == "Deposit" || transaction.TransactionType == "Bonus")
                {
                    transaction.CheckingAccountAffected.Balance -= transaction.Amount;
                    transaction.CheckingAccountAffected.Balance += transaction.Dispute.CorrectAmount;
                    transaction.Amount = transaction.Dispute.CorrectAmount;
                    transaction.Dispute.CurrentStatus = "Accepted";
                    db.SaveChanges();
                    return(RedirectToAction("ResolveDisputeConfirmation"));
                }
            }
            else if (transaction.SavingsAccountAffected != null)
            {
                EmailMessaging.SendEmail(transaction.SavingsAccountAffected.Customer.Email, "Dispute Adjusted", "The manager has adjusted your dispute. ");
                if (transaction.TransactionType == "Withdrawal" || transaction.TransactionType == "Bill Payment" || transaction.TransactionType == "Fee")
                {
                    transaction.SavingsAccountAffected.Balance += transaction.Amount;
                    transaction.SavingsAccountAffected.Balance -= transaction.Dispute.CorrectAmount;
                    transaction.Amount = transaction.Dispute.CorrectAmount;
                    transaction.Dispute.CurrentStatus = "Accepted";
                    db.SaveChanges();
                    return(RedirectToAction("ResolveDisputeConfirmation"));
                }
                else if (transaction.TransactionType == "Deposit" || transaction.TransactionType == "Bonus")
                {
                    transaction.SavingsAccountAffected.Balance -= transaction.Amount;
                    transaction.SavingsAccountAffected.Balance += transaction.Dispute.CorrectAmount;
                    transaction.Amount = transaction.Dispute.CorrectAmount;
                    transaction.Dispute.CurrentStatus = "Accepted";
                    db.SaveChanges();
                    return(RedirectToAction("ResolveDisputeConfirmation"));
                }
            }
            else if (transaction.IRAccountAffected != null)
            {
                EmailMessaging.SendEmail(transaction.IRAccountAffected.Customer.Email, "Dispute Adjusted", "The manager has adjusted your dispute. ");
                if (transaction.TransactionType == "Withdrawal" || transaction.TransactionType == "Bill Payment" || transaction.TransactionType == "Fee")
                {
                    transaction.IRAccountAffected.Balance += transaction.Amount;
                    transaction.IRAccountAffected.Balance -= transaction.Dispute.CorrectAmount;
                    transaction.Amount = transaction.Dispute.CorrectAmount;
                    transaction.Dispute.CurrentStatus = "Accepted";
                    db.SaveChanges();
                    return(RedirectToAction("ResolveDisputeConfirmation"));
                }
                else if (transaction.TransactionType == "Deposit" || transaction.TransactionType == "Bonus")
                {
                    transaction.IRAccountAffected.Balance -= transaction.Amount;
                    transaction.IRAccountAffected.Balance += transaction.Dispute.CorrectAmount;
                    transaction.Amount = transaction.Dispute.CorrectAmount;
                    transaction.Dispute.CurrentStatus = "Accepted";
                    db.SaveChanges();
                    return(RedirectToAction("ResolveDisputeConfirmation"));
                }
            }
            else if (transaction.StockPortfolioAffected != null)
            {
                EmailMessaging.SendEmail(transaction.StockPortfolioAffected.Customer.Email, "Dispute Adjusted", "The manager has adjusted your dispute. ");

                if (transaction.TransactionType == "Withdrawal" || transaction.TransactionType == "Bill Payment" || transaction.TransactionType == "Fee")
                {
                    transaction.StockPortfolioAffected.CashValueBalance += transaction.Amount;
                    transaction.StockPortfolioAffected.CashValueBalance -= transaction.Dispute.CorrectAmount;
                    transaction.Amount = transaction.Dispute.CorrectAmount;
                    transaction.Dispute.CurrentStatus = "Accepted";
                    db.SaveChanges();
                    return(RedirectToAction("ResolveDisputeConfirmation"));
                }
                else if (transaction.TransactionType == "Deposit" || transaction.TransactionType == "Bonus")
                {
                    transaction.StockPortfolioAffected.CashValueBalance -= transaction.Amount;
                    transaction.StockPortfolioAffected.CashValueBalance += transaction.Dispute.CorrectAmount;
                    transaction.Amount = transaction.Dispute.CorrectAmount;
                    transaction.Dispute.CurrentStatus = "Accepted";
                    db.SaveChanges();
                    return(RedirectToAction("ResolveDisputeConfirmation"));
                }
            }
            else if (transaction.TransferToCheckingAccount != null)
            {
                EmailMessaging.SendEmail(transaction.CheckingAccountAffected.Customer.Email, "Dispute Adjusted", "The manager has adjusted your dispute. ");
                CheckingAccount CheckingAccountToAffect = transaction.TransferToCheckingAccount;
                CheckingAccountToAffect.Balance -= transaction.Amount;
                CheckingAccountToAffect.Balance += transaction.Dispute.CorrectAmount;
                transaction.Amount = transaction.Dispute.CorrectAmount;
                transaction.Dispute.CurrentStatus = "Accepted";
                db.SaveChanges();
                return(RedirectToAction("ResolveDisputeConfirmed"));
            }
            else if (transaction.TransferFromCheckingAccount != null)
            {
                CheckingAccount CheckingAccountToAffect = transaction.TransferFromCheckingAccount;
                CheckingAccountToAffect.Balance += transaction.Amount;
                CheckingAccountToAffect.Balance -= transaction.Dispute.CorrectAmount;
                transaction.Amount = transaction.Dispute.CorrectAmount;
                transaction.Dispute.CurrentStatus = "Accepted";
                db.SaveChanges();
                return(RedirectToAction("ResolveDisputeConfirmed"));
            }
            else if (transaction.TransferToSavingsAccount != null)
            {
                SavingsAccount SavingsAccountToAffect = transaction.TransferToSavingsAccount;
                SavingsAccountToAffect.Balance   -= transaction.Amount;
                SavingsAccountToAffect.Balance   += transaction.Dispute.CorrectAmount;
                transaction.Amount                = transaction.Dispute.CorrectAmount;
                transaction.Dispute.CurrentStatus = "Accepted";
                db.SaveChanges();
                return(RedirectToAction("ResolveDisputeConfirmed"));
            }
            else if (transaction.TransferFromSavingsAccount != null)
            {
                SavingsAccount SavingsAccountToAffect = transaction.TransferFromSavingsAccount;
                SavingsAccountToAffect.Balance   += transaction.Amount;
                SavingsAccountToAffect.Balance   -= transaction.Dispute.CorrectAmount;
                transaction.Amount                = transaction.Dispute.CorrectAmount;
                transaction.Dispute.CurrentStatus = "Accepted";
                db.SaveChanges();
                return(RedirectToAction("ResolveDisputeConfirmed"));
            }
            else if (transaction.TransferToIRAccount != null)
            {
                IRAccount IRAccountToAffect = transaction.TransferToIRAccount;
                IRAccountToAffect.Balance        -= transaction.Amount;
                IRAccountToAffect.Balance        += transaction.Dispute.CorrectAmount;
                transaction.Amount                = transaction.Dispute.CorrectAmount;
                transaction.Dispute.CurrentStatus = "Accepted";
                db.SaveChanges();
                return(RedirectToAction("ResolveDisputeConfirmed"));
            }
            else if (transaction.TransferFromIRAccount != null)
            {
                IRAccount IRAccountToAffect = transaction.TransferFromIRAccount;
                IRAccountToAffect.Balance        += transaction.Amount;
                IRAccountToAffect.Balance        -= transaction.Dispute.CorrectAmount;
                transaction.Amount                = transaction.Dispute.CorrectAmount;
                transaction.Dispute.CurrentStatus = "Accepted";
                db.SaveChanges();
                return(RedirectToAction("ResolveDisputeConfirmed"));
            }
            else if (transaction.TransferFromStockPortfolio != null)
            {
                StockPortfolio StockPortfolioToAffect = transaction.TransferFromStockPortfolio;
                StockPortfolioToAffect.CashValueBalance += transaction.Amount;
                StockPortfolioToAffect.CashValueBalance -= transaction.Dispute.CorrectAmount;
                transaction.Amount = transaction.Dispute.CorrectAmount;
                transaction.Dispute.CurrentStatus = "Accepted";
                db.SaveChanges();
                return(RedirectToAction("ResolveDisputeConfirmed"));
            }
            else if (transaction.TransferToStockPortfolio != null)
            {
                StockPortfolio StockPortfolioToAffect = transaction.TransferToStockPortfolio;
                StockPortfolioToAffect.CashValueBalance -= transaction.Amount;
                StockPortfolioToAffect.CashValueBalance += transaction.Dispute.CorrectAmount;
                transaction.Amount = transaction.Dispute.CorrectAmount;
                transaction.Dispute.CurrentStatus = "Accepted";
                db.SaveChanges();
                return(RedirectToAction("ResolveDisputeConfirmed"));
            }

            return(RedirectToAction("EmployeePortal", "Manage"));
        }
示例#33
0
 public Customer(String name)
 {
     _name = name;
     _checkingsAccount = new CheckingsAccount();
     _savingsAccount = new SavingsAccount();
 }
        public ActionResult PurchaseStock([Bind(Include = "StockPurchaseID,PurchaseDate,NumberOfShares")] StockPurchase stockPurchase, int SavingsAccountID, int StockID)
        {
            if (ModelState.IsValid)
            {
                AppUser        user           = db.Users.Find(User.Identity.GetUserId());
                StockPortfolio stockPortfolio = user.StockPortfolio;
                SavingsAccount savingsAccount = db.SavingsAccounts.Find(SavingsAccountID);
                Stock          stock          = db.Stocks.Find(StockID);
                stockPurchase.StockPortfolio = stockPortfolio;
                stockPurchase.Stock          = stock;
                stockPortfolio.StockPurchases.Add(stockPurchase);
                stock.StockPurchases.Add(stockPurchase);
                StockQuote quote      = GetQuote.GetStock(stock.TickerSymbol, stockPurchase.PurchaseDate);
                Decimal    stockPrice = quote.PreviousClose;

                stockPurchase.InitialSharePrice    = stockPrice;
                stockPurchase.TotalStockValue      = stockPrice * stockPurchase.NumberOfShares;
                stockPurchase.ChangeInPrice        = stockPrice - stockPurchase.InitialSharePrice;
                stockPurchase.TotalChange          = stockPurchase.TotalStockValue - (stockPurchase.InitialSharePrice * stockPurchase.NumberOfShares);
                stockPurchase.StockPurchaseDisplay = stockPurchase.Stock.StockName + ", Current Price: $" + stock.CurrentPrice.ToString("c") + ", Number of shares: " + stockPurchase.NumberOfShares.ToString();
                if (savingsAccount.Balance < ((stockPurchase.InitialSharePrice * stockPurchase.NumberOfShares) + stockPurchase.Stock.Fee))
                {
                    return(View("Error", new string[] { "You do not have enough funds to make the purchase." }));
                }

                savingsAccount.Balance           -= ((stockPurchase.InitialSharePrice * stockPurchase.NumberOfShares) + stockPurchase.Stock.Fee);
                stockPortfolio.StockPortionValue += (stockPurchase.InitialSharePrice * stockPurchase.NumberOfShares);

                Transaction StockTransaction = new Transaction();
                StockTransaction.Amount = stockPurchase.InitialSharePrice * stockPurchase.NumberOfShares;
                StockTransaction.SavingsAccountAffected = savingsAccount;
                StockTransaction.Description            = "Stock Purchase - Account " + stockPortfolio.AccountNumber.ToString();
                StockTransaction.TransactionDate        = stockPurchase.PurchaseDate;
                StockTransaction.TransactionType        = "Withdrawal";
                StockTransaction.isBeingDisputed        = false;
                StockTransaction.isPending        = false;
                StockTransaction.EmployeeComments = "";

                Transaction TransactionFee = new Transaction();
                TransactionFee.Amount = stockPurchase.Stock.Fee;
                TransactionFee.SavingsAccountAffected = savingsAccount;
                TransactionFee.Description            = "Fee for purchase of " + stockPurchase.Stock.StockName;
                TransactionFee.TransactionDate        = stockPurchase.PurchaseDate;
                TransactionFee.TransactionType        = "Fee";
                TransactionFee.isBeingDisputed        = false;
                TransactionFee.isPending        = false;
                TransactionFee.EmployeeComments = "";

                int OrdinaryCount = 0;
                int IndexCount    = 0;
                int MutalCount    = 0;
                foreach (var s in stockPortfolio.StockPurchases)
                {
                    if (s.Stock.StockType.Equals("Ordinary Stock"))
                    {
                        OrdinaryCount += 1;
                    }
                    else if (s.Stock.StockType.Equals("Index Fund"))
                    {
                        IndexCount += 1;
                    }
                    else if (s.Stock.StockType.Equals("Mutual Fund"))
                    {
                        MutalCount += 1;
                    }
                }
                if (OrdinaryCount >= 2 && IndexCount >= 1 && MutalCount >= 1)
                {
                    stockPortfolio.isBalanced = true;
                }
                else
                {
                    stockPortfolio.isBalanced = false;
                }

                savingsAccount.Transactions.Add(StockTransaction);
                savingsAccount.Transactions.Add(TransactionFee);
                db.Transactions.Add(StockTransaction);
                db.Transactions.Add(TransactionFee);
                db.StockPurchases.Add(stockPurchase);
                db.SaveChanges();
                return(RedirectToAction("PurchaseStockConfirmation", "StockPortfolios"));
            }

            ViewBag.SavingsAccounts = GetSavingsAccountsWithBalance();
            ViewBag.Stocks          = GetAvailableStocks();
            return(View(stockPurchase));
        }
示例#35
0
        static void Main(string[] args)
        {
            SavingsAccount       sav = new SavingsAccount(5, 0.12);
            ChequingAccount      che = new ChequingAccount(5, 0.12);
            GlobalSavingsAccount glo = new GlobalSavingsAccount(5, 0.12);
            Boolean success1         = false;


            while (success1 == false)
            {
                try
                {
                    Console.WriteLine("A: Savings B: Checking C: GlobalSavings Q: Exit");
                    String s = Console.ReadLine();



                    switch (s.ToUpper())
                    {
                    case "A":
                        Console.WriteLine("A: Deposit B: Withdrawal C: Close + Report R: Return to Bank Menu");
                        String a = Console.ReadLine();
                        switch (a.ToUpper())
                        {
                        case "A":
                            Console.WriteLine("How much would you like to deposit?");
                            string depositString = Console.ReadLine();
                            double deposit       = Convert.ToDouble(depositString);
                            sav.MakeDeposit(deposit);
                            break;

                        case "B":
                            Console.WriteLine("How much would you like to withdraw?");
                            string withdrawString = Console.ReadLine();
                            double withdraw       = Convert.ToDouble(withdrawString);
                            sav.MakeWithdrawl(withdraw);
                            break;

                        case "C":

                            Console.Write(sav.CloseAndReport());
                            break;

                        case "R":
                            // come back
                            break;
                        }
                        break;

                    case "B":
                        Console.WriteLine("A: Deposit B: Withdrawal C: Close + Report R: Return to Bank Menu");
                        String b = Console.ReadLine();
                        switch (b.ToUpper())
                        {
                        case "A":
                            Console.WriteLine("How much would you like to deposit?");
                            string depositString = Console.ReadLine();
                            double deposit       = Convert.ToDouble(depositString);
                            che.MakeDeposit(deposit);
                            break;

                        case "B":
                            Console.WriteLine("How much would you like to withdraw?");
                            string withdrawString = Console.ReadLine();
                            double withdraw       = Convert.ToDouble(withdrawString);
                            che.MakeWithdrawl(withdraw);
                            break;

                        case "C":
                            Console.Write(che.CloseAndReport());
                            break;

                        case "R":
                            //come back
                            break;
                        }
                        break;

                    case "C":
                        Console.WriteLine("A: Deposit B: Withdrawal C: Close + Report D: Report Balance in USD R: Return to Bank Menu");
                        String c = Console.ReadLine();
                        switch (c.ToUpper())
                        {
                        case "A":
                            Console.WriteLine("How much would you like to deposit?");
                            string depositString = Console.ReadLine();
                            double deposit       = Convert.ToDouble(depositString);
                            glo.MakeDeposit(deposit);
                            break;

                        case "B":
                            Console.WriteLine("How much would you like to withdraw?");
                            string withdrawString = Console.ReadLine();
                            double withdraw       = Convert.ToDouble(withdrawString);
                            glo.MakeWithdrawl(withdraw);
                            break;

                        case "C":
                            Console.WriteLine(glo.CloseAndReport());
                            break;

                        case "D":
                            Console.WriteLine(glo.USValue(0.76));

                            break;

                        case "R":
                            //Come back
                            break;
                        }
                        break;

                    case "Q":
                        success1 = true;
                        break;
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("Entered a incorrect value. ");
                }
                finally
                {
                }
            }
        }
示例#36
0
 public void MinimalFirstInterestRate() =>
 Assert.Equal(0.5f, SavingsAccount.InterestRate(0m));
 public void Annual_balance_update_for_large_negative_start_balance()
 {
     Assert.Equal(-157878.97174203m, SavingsAccount.AnnualBalanceUpdate(-152964.231m));
 }
 public void Interest_on_medium_balance()
 {
     Assert.Equal(81.0498379m, SavingsAccount.Interest(4999.99m));
 }
 public void Years_before_desired_balance_for_small_start_balance()
 {
     Assert.Equal(47, SavingsAccount.YearsBeforeDesiredBalance(100.0m, 125.80m));
 }
 public void Interest_on_large_balance()
 {
     Assert.Equal(856.3698m, SavingsAccount.Interest(34600.80m));
 }
 public void Minimal_first_interest_rate()
 {
     Assert.Equal(0.5f, SavingsAccount.InterestRate(0m));
 }
 public void Annual_balance_update_for_empty_start_balance()
 {
     Assert.Equal(0.0000m, SavingsAccount.AnnualBalanceUpdate(0.0m));
 }
 public void Small_negative_interest_rate()
 {
     Assert.Equal(-3.213f, SavingsAccount.InterestRate(-0.123m));
 }
 public void Annual_balance_update_for_small_positive_start_balance()
 {
     Assert.Equal(0.000001005m, SavingsAccount.AnnualBalanceUpdate(0.000001m));
 }
 public void Large_negative_interest_rate()
 {
     Assert.Equal(-3.213f, SavingsAccount.InterestRate(-152964.231m));
 }
 public void Tiny_first_interest_rate()
 {
     Assert.Equal(0.5f, SavingsAccount.InterestRate(0.000001m));
 }
示例#47
0
 public void MaximumFirstInterestRate() =>
 Assert.Equal(0.5f, SavingsAccount.InterestRate(999.9999m));
 public void WithdrawDoesNotOwerdraw()
 {
     IAccount account = new SavingsAccount(36241604394L, 100.0, new Customer());
     service.Withdraw(account, 150.0);
 }
示例#49
0
 public void TinyFirstInterestRate() =>
 Assert.Equal(0.5f, SavingsAccount.InterestRate(0.000001m));
示例#50
0
 private void Form1_Load(object sender, EventArgs e)
 {
     aCheckingAccount = new CheckingAccount("Mark Whalberg", 2948564, 8500.00, 7, 2.75, 0.00, 0.00);
     aSavingsAccount = new SavingsAccount("Mickey Mouse", 904736, 100000000, 5.00, 10);
 }
        public ActionResult Details(SavingsAccountDetailsViewModel model, String TransactionNumber, String DateRange, String Description, String TransactionType, String PriceRange, String RangeFrom, String RangeTo, SortBy TransactionNumberSort, SortBy TransactionTypeSort, SortBy DescriptionSort, SortBy AmountSort, SortBy DateSort)
        {
            int?id = model.SavingsAccountID;

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SavingsAccount savingsAccount = db.SavingsAccounts.Find(id);
            SavingsAccountDetailsViewModel modelToPass = new SavingsAccountDetailsViewModel {
                SavingsAccountID = id, SavingsAccount = savingsAccount, Transactions = savingsAccount.Transactions
            };

            if (savingsAccount == null)
            {
                return(HttpNotFound());
            }

            var query = from t in savingsAccount.Transactions
                        select t;

            if (TransactionNumber != null && TransactionNumber != "")
            {
                Int32 number;
                try
                {
                    number = Convert.ToInt32(TransactionNumber);
                    query  = query.Where(t => t.TransactionID.Equals(number));
                }
                catch
                {
                    ViewBag.TransactionNumberValidation = "Enter a whole number";
                    ViewBag.Count            = savingsAccount.Transactions.Count();
                    ViewBag.TransactionTypes = new SelectList(Utilities.Utility.TranscationTypes);
                    return(View(modelToPass));
                }
            }
            query = query.Where(t => t.Description.Contains(Description));
            if (!DateRange.Equals("Custom") && !DateRange.Equals("All"))
            {
                if (DateRange.Equals("Last 15 days"))
                {
                    query = query.Where(t => t.TransactionDate >= DateTime.Now.AddDays(-1));
                }
                else if (DateRange.Equals("Last 30 days"))
                {
                    query = query.Where(t => t.TransactionDate >= DateTime.Now.AddDays(-30));
                }
                else
                {
                    query = query.Where(t => t.TransactionDate >= DateTime.Now.AddDays(-60));
                }
            }
            if (DateRange.Equals("Custom"))
            {
                query = query.Where(t => t.TransactionDate >= model.DateFrom && t.TransactionDate <= model.DateTo);
            }
            if (!TransactionType.Equals("All"))
            {
                query = query.Where(t => t.TransactionType.Equals(TransactionType));
            }
            if (!PriceRange.Equals("Custom"))
            {
                if (PriceRange.Equals("$0-$100"))
                {
                    query = query.Where(t => t.Amount >= 0 && t.Amount <= 100);
                }
                else if (PriceRange.Equals("$100-$200"))
                {
                    query = query.Where(t => t.Amount >= 100 && t.Amount <= 200);
                }
                else if (PriceRange.Equals("$200-$300"))
                {
                    query = query.Where(t => t.Amount >= 200 && t.Amount <= 300);
                }
                else
                {
                    query = query.Where(t => t.Amount >= 300);
                }
            }
            else
            {
                Decimal rangeFrom;
                Decimal rangeTo;
                try
                {
                    rangeFrom = Convert.ToDecimal(RangeFrom);
                    rangeTo   = Convert.ToDecimal(RangeTo);
                    query     = query.Where(t => t.Amount >= rangeFrom && t.Amount <= rangeTo);
                }
                catch
                {
                    ViewBag.Message          = "Enter a valid range of numbers";
                    ViewBag.Count            = savingsAccount.Transactions.Count();
                    ViewBag.TransactionTypes = new SelectList(Utilities.Utility.TranscationTypes);
                    return(View(modelToPass));
                }
            }

            if (TransactionNumberSort.Equals(SortBy.Ascending))
            {
                if (TransactionTypeSort.Equals(SortBy.Ascending))
                {
                    if (DescriptionSort.Equals(SortBy.Ascending))
                    {
                        if (AmountSort.Equals(SortBy.Ascending))
                        {
                            if (DateSort.Equals(SortBy.Ascending))
                            {
                                query.OrderBy(t => t.TransactionID).ThenBy(t => t.TransactionType).ThenBy(t => t.Description).ThenBy(t => t.Amount).ThenBy(t => t.TransactionDate);
                            }
                            else
                            {
                                query.OrderBy(t => t.TransactionID).ThenBy(t => t.TransactionType).ThenBy(t => t.Description).ThenBy(t => t.Amount).ThenByDescending(t => t.TransactionDate);
                            }
                        }
                        else
                        {
                            if (DateSort.Equals(SortBy.Ascending))
                            {
                                query.OrderBy(t => t.TransactionID).ThenBy(t => t.TransactionType).ThenBy(t => t.Description).ThenByDescending(t => t.Amount).ThenBy(t => t.TransactionDate);
                            }
                            else
                            {
                                query.OrderBy(t => t.TransactionID).ThenBy(t => t.TransactionType).ThenBy(t => t.Description).ThenByDescending(t => t.Amount).ThenByDescending(t => t.TransactionDate);
                            }
                        }
                    }
                    else
                    {
                        if (AmountSort.Equals(SortBy.Ascending))
                        {
                            if (DateSort.Equals(SortBy.Ascending))
                            {
                                query.OrderBy(t => t.TransactionID).ThenBy(t => t.TransactionType).ThenByDescending(t => t.Description).ThenBy(t => t.Amount).ThenBy(t => t.TransactionDate);
                            }
                            else
                            {
                                query.OrderBy(t => t.TransactionID).ThenBy(t => t.TransactionType).ThenByDescending(t => t.Description).ThenBy(t => t.Amount).ThenByDescending(t => t.TransactionDate);
                            }
                        }
                        else
                        {
                            if (DateSort.Equals(SortBy.Ascending))
                            {
                                query.OrderBy(t => t.TransactionID).ThenBy(t => t.TransactionType).ThenByDescending(t => t.Description).ThenByDescending(t => t.Amount).ThenBy(t => t.TransactionDate);
                            }
                            else
                            {
                                query.OrderBy(t => t.TransactionID).ThenBy(t => t.TransactionType).ThenByDescending(t => t.Description).ThenByDescending(t => t.Amount).ThenByDescending(t => t.TransactionDate);
                            }
                        }
                    }
                }
                else
                {
                    if (DescriptionSort.Equals(SortBy.Ascending))
                    {
                        if (AmountSort.Equals(SortBy.Ascending))
                        {
                            if (DateSort.Equals(SortBy.Ascending))
                            {
                                query.OrderBy(t => t.TransactionID).ThenByDescending(t => t.TransactionType).ThenBy(t => t.Description).ThenBy(t => t.Amount).ThenBy(t => t.TransactionDate);
                            }
                            else
                            {
                                query.OrderBy(t => t.TransactionID).ThenByDescending(t => t.TransactionType).ThenBy(t => t.Description).ThenBy(t => t.Amount).ThenByDescending(t => t.TransactionDate);
                            }
                        }
                        else
                        {
                            if (DateSort.Equals(SortBy.Ascending))
                            {
                                query.OrderBy(t => t.TransactionID).ThenByDescending(t => t.TransactionType).ThenBy(t => t.Description).ThenByDescending(t => t.Amount).ThenBy(t => t.TransactionDate);
                            }
                            else
                            {
                                query.OrderBy(t => t.TransactionID).ThenByDescending(t => t.TransactionType).ThenBy(t => t.Description).ThenByDescending(t => t.Amount).ThenByDescending(t => t.TransactionDate);
                            }
                        }
                    }
                    else
                    {
                        if (AmountSort.Equals(SortBy.Ascending))
                        {
                            if (DateSort.Equals(SortBy.Ascending))
                            {
                                query.OrderBy(t => t.TransactionID).ThenByDescending(t => t.TransactionType).ThenByDescending(t => t.Description).ThenBy(t => t.Amount).ThenBy(t => t.TransactionDate);
                            }
                            else
                            {
                                query.OrderBy(t => t.TransactionID).ThenByDescending(t => t.TransactionType).ThenByDescending(t => t.Description).ThenBy(t => t.Amount).ThenByDescending(t => t.TransactionDate);
                            }
                        }
                        else
                        {
                            if (DateSort.Equals(SortBy.Ascending))
                            {
                                query.OrderBy(t => t.TransactionID).ThenByDescending(t => t.TransactionType).ThenByDescending(t => t.Description).ThenByDescending(t => t.Amount).ThenBy(t => t.TransactionDate);
                            }
                            else
                            {
                                query.OrderBy(t => t.TransactionID).ThenByDescending(t => t.TransactionType).ThenByDescending(t => t.Description).ThenByDescending(t => t.Amount).ThenByDescending(t => t.TransactionDate);
                            }
                        }
                    }
                }
            }
            else
            {
                if (TransactionTypeSort.Equals(SortBy.Ascending))
                {
                    if (DescriptionSort.Equals(SortBy.Ascending))
                    {
                        if (AmountSort.Equals(SortBy.Ascending))
                        {
                            if (DateSort.Equals(SortBy.Ascending))
                            {
                                query.OrderByDescending(t => t.TransactionID).ThenBy(t => t.TransactionType).ThenBy(t => t.Description).ThenBy(t => t.Amount).ThenBy(t => t.TransactionDate);
                            }
                            else
                            {
                                query.OrderByDescending(t => t.TransactionID).ThenBy(t => t.TransactionType).ThenBy(t => t.Description).ThenBy(t => t.Amount).ThenByDescending(t => t.TransactionDate);
                            }
                        }
                        else
                        {
                            if (DateSort.Equals(SortBy.Ascending))
                            {
                                query.OrderByDescending(t => t.TransactionID).ThenBy(t => t.TransactionType).ThenBy(t => t.Description).ThenByDescending(t => t.Amount).ThenBy(t => t.TransactionDate);
                            }
                            else
                            {
                                query.OrderByDescending(t => t.TransactionID).ThenBy(t => t.TransactionType).ThenBy(t => t.Description).ThenByDescending(t => t.Amount).ThenByDescending(t => t.TransactionDate);
                            }
                        }
                    }
                    else
                    {
                        if (AmountSort.Equals(SortBy.Ascending))
                        {
                            if (DateSort.Equals(SortBy.Ascending))
                            {
                                query.OrderByDescending(t => t.TransactionID).ThenBy(t => t.TransactionType).ThenByDescending(t => t.Description).ThenBy(t => t.Amount).ThenBy(t => t.TransactionDate);
                            }
                            else
                            {
                                query.OrderByDescending(t => t.TransactionID).ThenBy(t => t.TransactionType).ThenByDescending(t => t.Description).ThenBy(t => t.Amount).ThenByDescending(t => t.TransactionDate);
                            }
                        }
                        else
                        {
                            if (DateSort.Equals(SortBy.Ascending))
                            {
                                query.OrderByDescending(t => t.TransactionID).ThenBy(t => t.TransactionType).ThenByDescending(t => t.Description).ThenByDescending(t => t.Amount).ThenBy(t => t.TransactionDate);
                            }
                            else
                            {
                                query.OrderByDescending(t => t.TransactionID).ThenBy(t => t.TransactionType).ThenByDescending(t => t.Description).ThenByDescending(t => t.Amount).ThenByDescending(t => t.TransactionDate);
                            }
                        }
                    }
                }
                else
                {
                    if (DescriptionSort.Equals(SortBy.Ascending))
                    {
                        if (AmountSort.Equals(SortBy.Ascending))
                        {
                            if (DateSort.Equals(SortBy.Ascending))
                            {
                                query.OrderByDescending(t => t.TransactionID).ThenByDescending(t => t.TransactionType).ThenBy(t => t.Description).ThenBy(t => t.Amount).ThenBy(t => t.TransactionDate);
                            }
                            else
                            {
                                query.OrderByDescending(t => t.TransactionID).ThenByDescending(t => t.TransactionType).ThenBy(t => t.Description).ThenBy(t => t.Amount).ThenByDescending(t => t.TransactionDate);
                            }
                        }
                        else
                        {
                            if (DateSort.Equals(SortBy.Ascending))
                            {
                                query.OrderByDescending(t => t.TransactionID).ThenByDescending(t => t.TransactionType).ThenBy(t => t.Description).ThenByDescending(t => t.Amount).ThenBy(t => t.TransactionDate);
                            }
                            else
                            {
                                query.OrderByDescending(t => t.TransactionID).ThenByDescending(t => t.TransactionType).ThenBy(t => t.Description).ThenByDescending(t => t.Amount).ThenByDescending(t => t.TransactionDate);
                            }
                        }
                    }
                    else
                    {
                        if (AmountSort.Equals(SortBy.Ascending))
                        {
                            if (DateSort.Equals(SortBy.Ascending))
                            {
                                query.OrderByDescending(t => t.TransactionID).ThenByDescending(t => t.TransactionType).ThenByDescending(t => t.Description).ThenBy(t => t.Amount).ThenBy(t => t.TransactionDate);
                            }
                            else
                            {
                                query.OrderByDescending(t => t.TransactionID).ThenByDescending(t => t.TransactionType).ThenByDescending(t => t.Description).ThenBy(t => t.Amount).ThenByDescending(t => t.TransactionDate);
                            }
                        }
                        else
                        {
                            if (DateSort.Equals(SortBy.Ascending))
                            {
                                query.OrderByDescending(t => t.TransactionID).ThenByDescending(t => t.TransactionType).ThenByDescending(t => t.Description).ThenByDescending(t => t.Amount).ThenBy(t => t.TransactionDate);
                            }
                            else
                            {
                                query.OrderByDescending(t => t.TransactionID).ThenByDescending(t => t.TransactionType).ThenByDescending(t => t.Description).ThenByDescending(t => t.Amount).ThenByDescending(t => t.TransactionDate);
                            }
                        }
                    }
                }
            }

            query.OrderByDescending(t => t.TransactionID);
            List <Transaction> list = query.ToList();

            modelToPass = new SavingsAccountDetailsViewModel {
                SavingsAccountID = id, SavingsAccount = savingsAccount, Transactions = list
            };
            ViewBag.Count            = list.Count();
            ViewBag.TransactionTypes = new SelectList(Utilities.Utility.TranscationTypes);
            return(View(modelToPass));
        }
示例#52
0
        public void ZeroSumRefillBigSumAccount()
        {
            BaseAccount account = new SavingsAccount(Guid.NewGuid(), 10000000000000);

            account.Refill(0);
        }
 public SavingsBuilder()
 {
     this.account = new SavingsAccount();
 }
示例#54
0
        public void RefillNegativeSum()
        {
            BaseAccount account = new SavingsAccount(Guid.NewGuid(), 1000);

            account.Refill(-100);
        }
示例#55
0
        public bool CreateSavingsAccount()
        {
            SavingsAccount savingsAccount = new SavingsAccount();

            return(AddAccount(savingsAccount));
        }
示例#56
0
 public Transfer(SavingsAccount acct1, CheckingAccount acct2, Money m)
 {
 }