コード例 #1
0
ファイル: BankController.cs プロジェクト: petramille/ATM
        // GET: Landing
        // Confirmation page when taking out money
        public ActionResult Landing(string quantity, string account)
        {
            // Create BankLogic object and prepare variables
            BankLogic bankLogic = new BankLogic();
            int sum = int.Parse(quantity);

            // Get number of bills that was taken out and if transaction was successfull
            List<string> receipt = (List<string>)Session["numberOfBills"];
            List<string> message = bankLogic.WithdrawFromAccount(sum, account);

            if (message[0] == "Ok")
            {
                WithdrawalConfirmation confirm = new WithdrawalConfirmation();

                // Check if unit has receipt paper
                if (int.Parse(receipt[4]) < 1)
                {
                    confirm.receipt = "disabled";
                }

                // Prepare variables to be passsed to view
                confirm.sum = quantity;
                confirm.account = account;
                confirm.value100 = message[1];
                confirm.value200 = message[2];
                confirm.value500 = message[3];
                confirm.value1000 = message[4];

                return View(confirm);

            }
            else
            {
                return this.RedirectToAction("Error", "Bank", new { error = message[1] });
            }
        }