예제 #1
0
        public ActionResult History(string accountNumber)
        {
            // Check if account number is valid
            if (!string.IsNullOrEmpty(accountNumber))
            {
                // Create BankLogic object and get 5 latest events
                BankLogic bankLogic = new BankLogic();
                List<string> accountHistory = bankLogic.GetAccountInformation(accountNumber, 5);

                // If error is returned go to error page and display error
                if (accountHistory[0] == "false")
                {
                    return this.RedirectToAction("Error", "Bank", new { error = accountHistory[1] });
                }

                else
                {
                    AccountInformation accountInfo = new AccountInformation();

                    List<string> receipt = (List<string>)Session["numberOfBills"];

                    // Check if unit has receipt paper
                    if (int.Parse(receipt[4]) < 2)
                    {
                        //Disable receipt button
                        accountInfo.receipt = "disabled";
                    }

                    // List all account events
                    for (int i = 2; i < accountHistory.Count; i++)
                    {
                        accountInfo.entry.Add(accountHistory[i]);
                    }

                    // Add account info to be displayed in view
                    accountInfo.accountRaw = accountNumber;
                    accountInfo.account = accountHistory[0];

                    //Get session info and add to event log
                    string ssn = (string)Session["SSN"];
                    bankLogic.LoggingOfEvents("View_amount", ssn, accountNumber, 0);

                    return View(accountInfo);
                }
            }
            else
            {
                return this.RedirectToAction("Index", "Bank");
            }
        }
예제 #2
0
        public ActionResult Receipt(string acc, string quantity, string accRaw)
        {
            // Create BankLogic Object
            BankLogic bankLogic = new BankLogic();

            // Check if the receipt is for withdrawal
            if (string.IsNullOrEmpty(accRaw))
            {
                // Remove one length
                bankLogic.subtractFromReceipt(1, (string)Session["ATMID"]);

                // Prepare receipt info to be passed in to view
                Receipt receipt = new Receipt();
                receipt.acc = acc;
                receipt.sum = quantity;
                receipt.receiptType = 1;

                // Log receipt event
                string ssn = (string)Session["SSN"];
                bankLogic.LoggingOfEvents("Print_Success", ssn, " ", 0);

                return View(receipt);
            }

            //Check if the receipt is for history and balance
            else if (!string.IsNullOrEmpty(accRaw))
            {
                // Prepare variables and objects
                Receipt receipt = new Receipt();
                List<string> accountHistory = bankLogic.GetAccountInformation(accRaw, 25);

                // Remove two lengths
                bankLogic.subtractFromReceipt(2, (string)Session["ATMID"]);

                // Prepare receipt info to be passed in to view
                for (int i = 2; i < accountHistory.Count; i++)
                {
                    receipt.entry.Add(accountHistory[i]);
                }
                receipt.acc = acc;
                receipt.receiptType = 2;

                // Log receipt event
                string ssn = (string)Session["SSN"];
                bankLogic.LoggingOfEvents("Print_Success", ssn, " ", 0);

                return View(receipt);
            }
            else
            {
                return this.RedirectToAction("Index", "Home");
            }
        }