コード例 #1
0
        public ActionResult PayBillsOnlineSavings()
        {
            AppUser                 user = db.Users.Find(User.Identity.GetUserId());
            List <Payee>            CustomerPayeeList = user.Payees.ToList();
            PayBillsOnlineViewModel model             = new PayBillsOnlineViewModel {
                Customer = user, Payees = CustomerPayeeList
            };

            if (user.IsActive)
            {
                ViewBag.Payees = GetSavingsAccountsWithBalance();
                return(View(model));
            }
            return(View("Error", new string[] { "Your account is inactive." }));
        }
コード例 #2
0
        public ActionResult PayBillsOnlineSavings([Bind(Include = "TransactionID,TransactionDate,Amount,Description")] Transaction transaction, int SavingsAccountID)
        {
            if (ModelState.IsValid)
            {
                transaction.TransactionType  = "Bill Payment";
                transaction.isBeingDisputed  = false;
                transaction.EmployeeComments = "";
                transaction.isPending        = false;
                if (transaction.Description == null)
                {
                    transaction.Description = "";
                }
                SavingsAccount SavingsAccountToChange = db.SavingsAccounts.Find(SavingsAccountID);

                if (SavingsAccountToChange.Balance < 0)
                {
                    return(View("Error", new string[] { "You cannot transfer money with a negative balance" }));
                }



                if (transaction.Amount > SavingsAccountToChange.Balance)
                {
                    if ((transaction.Amount - SavingsAccountToChange.Balance) > 50)
                    {
                        return(View("Error", new string[] { "The transaction exceeds the $50 overdraft limit. Please try to input a transfer amount within Balance range or $50 overdraft limit range" }));
                    }
                    else
                    {
                        Transaction TransactionODFee = new Transaction();
                        TransactionODFee.Amount           = 30;
                        SavingsAccountToChange.Balance   -= TransactionODFee.Amount;
                        TransactionODFee.TransactionDate  = transaction.TransactionDate;
                        TransactionODFee.TransactionType  = "Fee";
                        TransactionODFee.isBeingDisputed  = false;
                        TransactionODFee.EmployeeComments = "";
                        TransactionODFee.isPending        = false;
                        TransactionODFee.Description      = "Overdraft Fee";

                        TransactionODFee.SavingsAccountAffected = SavingsAccountToChange;
                        SavingsAccountToChange.Transactions.Add(TransactionODFee);
                        db.Transactions.Add(TransactionODFee);

                        EmailMessaging.SendEmail(TransactionODFee.SavingsAccountAffected.Customer.Email, "Overdraft", "Your account is now in overdraft status. ");
                    }
                }

                SavingsAccountToChange.Balance    -= transaction.Amount;
                transaction.SavingsAccountAffected = SavingsAccountToChange;
                SavingsAccountToChange.Transactions.Add(transaction);
                db.Transactions.Add(transaction);
                db.SaveChanges();
                return(RedirectToAction("PaymentConfirmation", "Payees"));
            }
            AppUser                 user = db.Users.Find(User.Identity.GetUserId());
            List <Payee>            CustomerPayeeList = user.Payees.ToList();
            PayBillsOnlineViewModel model             = new PayBillsOnlineViewModel {
                Customer = user, Payees = CustomerPayeeList
            };

            ViewBag.Payees = GetSavingsAccountsWithBalance();
            return(View(model));
        }