Esempio n. 1
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");
            }
        }