コード例 #1
0
    protected void btnComfirmToNext_Click(object sender, EventArgs e)
    {
        int customerId = 0;

        Int32.TryParse(((String)Session["selTransferee"]).Substring(0, 4), out customerId);


        TransferTransaction transaction = new TransferTransaction(Convert.ToDouble(Session["amount"]));

        if ((int)Session["accountTypeIndex"] == 0)
        {
            transaction.FromAccount = customers[(int)Session["selCustomerIndex"] - 1].Checking;
        }
        else
        {
            transaction.FromAccount = customers[(int)Session["selCustomerIndex"] - 1].Saving;
        }

        if ((int)Session["accountTransfereeIndex"] == 0)
        {
            transaction.ToAccount = Customer.GetCustomerById(customerId).Checking;
        }
        else
        {
            transaction.ToAccount = Customer.GetCustomerById(customerId).Saving;
        }

        TransactionResult result = transaction.Execute();

        Session["result"] = result;

        Response.Redirect("FundTransferResult.aspx");
    }
        public void Transfer_Execute_WithdrawBalanceUpdatesOK()
        {
            TransferTransaction transfer = new TransferTransaction(from, to, 50);

            _ = transfer.Execute();
            Assert.Equal(50, from.Balance);
        }
        public void Transfer_Execute_DepositBalanceUpdatesOK()
        {
            TransferTransaction transfer = new TransferTransaction(from, to, 50);

            _ = transfer.Execute();
            Assert.Equal(150, to.Balance);
        }
        public void Transfer_Executes_StatusComplete()
        {
            TransferTransaction transfer = new TransferTransaction(from, to, 50);

            _ = transfer.Execute();
            Assert.Equal("Complete", transfer.Status);
        }
        public void Transfer_Executes_ExecutedIsTrue()
        {
            TransferTransaction transfer = new TransferTransaction(from, to, 50);

            _ = transfer.Execute();
            Assert.True(transfer.Executed);
        }
        public void Transfer_Rollback_OK()
        {
            TransferTransaction transfer = new TransferTransaction(from, to, 50);

            _ = transfer.Execute();
            _ = transfer.Rollback();
            Assert.True(transfer.Reversed);
        }
        public void Transfer_RollbackWithInsufficientFunds_ThrowsInsufficientFundsException()
        {
            TransferTransaction transfer = new TransferTransaction(from, to, 50);

            _ = transfer.Execute();

            WithdrawTransaction withdraw = new WithdrawTransaction(to, to.Balance);

            withdraw.Execute();

            Assert.Throws <InsufficientFundsException>(() => transfer.Rollback());
        }
 private void TransferenciaATM()
 {
     try
     {
         ITransaction transacao = new TransferTransaction(new ATMUI(300));
         transacao.Execute();
         Console.WriteLine("Valor transferido com sucesso.");
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
コード例 #9
0
    // User Clicked Next
    protected void Confirmation_complete_Click(object sender, System.EventArgs e)
    {
        // Variables
        Customer selectedTransferor = (Customer)Session["selectedTransferor"];
        Customer selectedTransferee = (Customer)Session["selectedTransferee"];
        string   toAccount          = (string)Session["toAccount"];
        string   fromAccount        = (string)Session["fromAccount"];
        double   amount             = (double)Session["amount"];

        // TransferTransaction
        TransferTransaction transfer = new TransferTransaction(amount);

        // From Account
        // Checking
        if (fromAccount == "Checking")
        {
            transfer.FromAccount = selectedTransferor.Checking;
            // Saving
        }
        else
        {
            transfer.FromAccount = selectedTransferor.Saving;
        }

        // To Account
        // Checking
        if (toAccount == "Checking")
        {
            transfer.ToAccount = selectedTransferee.Checking;
            // Saving
        }
        else
        {
            transfer.ToAccount = selectedTransferee.Saving;
        }

        // Execute Transfer
        transfer.Execute();

        // Next Page
        Response.Redirect("/FundTransferResult.aspx");
    }
コード例 #10
0
 private void ExecuteTransaction(TransferTransaction TransferTransaction)
 {
     TransferTransaction.Execute();
 }
コード例 #11
0
ファイル: Bank.cs プロジェクト: tdzinotyiweyi/Projectworks
 public void ExecuteTransaction(TransferTransaction transaction)
 {
     transaction.Execute();
 }
コード例 #12
0
 public static void ExecuteTransaction(TransferTransaction transaction)
 {
     transaction.Execute();
     transaction.Print();
 }