예제 #1
0
        public async Task <IActionResult> Payment(Payment payment)
        {
            ViewBag.Templates = await GetTemplates();

            ViewBag.BankCodes = DataHandler.GetBankCodes();

            if (ModelState.IsValid)
            {
                User   user   = null;
                string userId = HttpContext.Session.GetString("UserId");
                SessionHandler.GetUser(userId, out user);

                if (user.Money < payment.Amount)
                {
                    ViewBag.Insufficient = "Insufficient money.";
                    return(View(payment));
                }

                if (payment.DestBank == 666 && !_context.AccountExist(payment.DestAccount))
                {
                    return(View("NoAccount", payment));
                }

                int t = TransactionHandler.NewPayment(user, payment);
                HttpContext.Session.SetInt32("Payment", t);
                return(View("PaymentConfirm", payment));
            }

            ViewBag.ErrMsg = "Values are not valid.";
            return(View(payment));
        }