public ActionResult Create([Bind(Include = "IRAccountID,AccountNum,AccountName,Balance")] IRAccount irAccount)
        {
            if (ModelState.IsValid)
            {
                if (irAccount.Balance < 0)
                {
                    return(Content("<script language'javascript' type = 'text/javascript'> alert('Error: Your starting balance must be positive.'); window.location='../IRAccount/Create';</script>"));
                }
                AppUser user = db.Users.Find(User.Identity.GetUserId());

                Transaction t = new Transaction();
                t.Date        = DateTime.Today;
                t.ToAccount   = irAccount.AccountNum;
                t.TransType   = TransType.Deposit;
                t.Description = "Initial deposit";
                t.Amount      = irAccount.Balance;
                if (irAccount.Balance > 5000)
                {
                    irAccount.Balance = 0;
                    t.NeedsApproval   = true;
                }

                irAccount.Transactions = new List <Transaction>();
                irAccount.Transactions.Add(t);

                user.IRAccount = irAccount;
                db.SaveChanges();
                return(Content("<script language'javascript' type = 'text/javascript'> alert('Confirmation: You have successfully created an IRA!'); window.location='../Customer/Home';</script>"));
            }
            return(View(irAccount));
        }
        public ActionResult EditName(String id)
        {
            if (db.Users.Find(User.Identity.GetUserId()).Disabled == true)
            {
                return(Content("<script language'javascript' type = 'text/javascript'> alert('Access Denied: Your account has been disabled. You are in a view-only mode.'); window.location='../Customer/Home';</script>"));
            }

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            IRAccount irAccount = db.IRAccounts.Find(id);

            if (irAccount == null)
            {
                return(HttpNotFound());
            }

            ViewBag.AccountID = id;
            EditAccountNameViewModel editAccountNameVM = new EditAccountNameViewModel();

            editAccountNameVM.AccountName = irAccount.AccountName;

            return(View(editAccountNameVM));
        }
        public IRAccount GetIRAccount()
        {
            AppUser   user      = db.Users.Find(User.Identity.GetUserId());
            IRAccount irAccount = user.IRAccount;

            return(irAccount);
        }
Example #4
0
        public ActionResult DeleteConfirmed(int id)
        {
            IRAccount iRAccount = db.IRAccounts.Find(id);

            db.IRAccounts.Remove(iRAccount);
            db.SaveChanges();
            return(RedirectToAction("MyBankAccounts", "Account"));
        }
Example #5
0
 public ActionResult Edit(IRAccount iRAccount)
 {
     if (ModelState.IsValid)
     {
         db.Entry(iRAccount).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("MyBankAccounts", "Account"));
     }
     return(View(iRAccount));
 }
        public List <AccountsViewModel> GetListAccounts()
        {
            AppUser user = db.Users.Find(User.Identity.GetUserId());
            List <AccountsViewModel> allAccounts = new List <AccountsViewModel>();

            if (user.CheckingAccounts != null)
            {
                List <CheckingAccount> checkingAccounts = user.CheckingAccounts.ToList <CheckingAccount>();
                // get checkings
                foreach (var c in checkingAccounts)
                {
                    AccountsViewModel accountToAdd = new AccountsViewModel();
                    accountToAdd.AccountNum  = c.AccountNum;
                    accountToAdd.AccountName = c.AccountName;
                    accountToAdd.Balance     = c.Balance;
                    allAccounts.Add(accountToAdd);
                }
            }

            if (user.IRAccount != null)
            {
                IRAccount i = user.IRAccount;
                // get checkings
                AccountsViewModel accountToAdd = new AccountsViewModel();
                accountToAdd.AccountNum  = i.AccountNum;
                accountToAdd.AccountName = i.AccountName;
                accountToAdd.Balance     = i.Balance;
                allAccounts.Add(accountToAdd);
            }

            if (user.SavingAccounts != null)
            {
                List <SavingAccount> savingAccounts = user.SavingAccounts.ToList <SavingAccount>();
                // get savings
                foreach (var s in savingAccounts)
                {
                    AccountsViewModel accountToAdd = new AccountsViewModel();
                    accountToAdd.AccountNum  = s.AccountNum;
                    accountToAdd.AccountName = s.AccountName;
                    accountToAdd.Balance     = s.Balance;
                    allAccounts.Add(accountToAdd);
                }
            }
            if (user.StockPortfolio != null)
            {
                StockPortfolio stockPortfolio = user.StockPortfolio;
                // get cash portion stock portfolio
                AccountsViewModel p = new AccountsViewModel();
                p.AccountNum  = stockPortfolio.AccountNum;
                p.AccountName = stockPortfolio.AccountName;
                p.Balance     = stockPortfolio.Balance;
                allAccounts.Add(p);
            }
            return(allAccounts);
        }
Example #7
0
        public SelectList GetIRAccounts()
        {
            AppUser          user          = db.Users.Find(User.Identity.GetUserId());
            IRAccount        iRAccount     = user.IRAccount;
            List <IRAccount> iRAccountlist = new List <IRAccount>();

            iRAccountlist.Add(user.IRAccount);
            SelectList list = new SelectList(iRAccountlist, "IRAccountID", "AccountName");

            return(list);
        }
 public ActionResult EditName([Bind(Include = "AccountName")] EditAccountNameViewModel vm, String id)
 {
     if (ModelState.IsValid)
     {
         IRAccount irAccount = db.IRAccounts.Find(id);
         irAccount.AccountName = vm.AccountName;
         db.SaveChanges();
         return(Content("<script language'javascript' type = 'text/javascript'> alert('Confirmation: IRA name updated.'); window.location='../Customer/Home';</script>"));
     }
     return(View(vm));
 }
        public String GetAccountType(Int32?accountNum)
        {
            AppUser user = db.Users.Find(User.Identity.GetUserId());
            String  accountType;

            List <CheckingAccount> checkingAccounts = user.CheckingAccounts;

            foreach (var c in checkingAccounts)
            {
                if (accountNum == c.AccountNum)
                {
                    accountType = "CHECKING";
                    return(accountType);
                }
            }

            List <SavingAccount> savingAccounts = user.SavingAccounts;

            foreach (var s in savingAccounts)
            {
                if (accountNum == s.AccountNum)
                {
                    accountType = "SAVING";
                    return(accountType);
                }
            }

            IRAccount iraAccount = user.IRAccount;

            if (iraAccount != null)
            {
                if (accountNum == iraAccount.AccountNum)
                {
                    accountType = "IRA";
                    return(accountType);
                }
            }


            StockPortfolio stockPortfolio = user.StockPortfolio;

            if (stockPortfolio != null)
            {
                if (accountNum == stockPortfolio.AccountNum)
                {
                    accountType = "STOCKPORTFOLIO";
                    return(accountType);
                }
            }

            return("NOT FOUND");
        }
        public List <Transaction> GetAllTransactions(String id)
        {
            IRAccount          irAccount    = db.IRAccounts.Find(id);
            List <Transaction> transactions = new List <Transaction>();

            foreach (Transaction t in irAccount.Transactions)
            {
                if (t.NeedsApproval != true)
                {
                    transactions.Add(t);
                }
            }
            return(transactions);
        }
Example #11
0
        // GET: IRAccounts/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            IRAccount iRAccount = db.IRAccounts.Find(id);

            if (iRAccount == null)
            {
                return(HttpNotFound());
            }
            return(View(iRAccount));
        }
        public bool OverdraftStatus()
        {
            // get all accounts
            // check if overdrafted
            bool isOverdraft = false;

            List <CheckingAccount> checkingAccounts = GetAllCheckingAccts();

            foreach (CheckingAccount c in checkingAccounts)
            {
                if (c.Balance < 0)
                {
                    isOverdraft = true;
                }
            }

            List <SavingAccount> savingAccounts = GetAllSavingAccts();

            foreach (SavingAccount s in savingAccounts)
            {
                if (s.Balance < 0)
                {
                    isOverdraft = true;
                }
            }

            IRAccount irAccount = GetIRAccount();

            if (irAccount != null)
            {
                if (irAccount.Balance < 0)
                {
                    isOverdraft = true;
                }
            }

            StockPortfolio portfolio = GetStockPortfolio();

            if (portfolio != null)
            {
                if (portfolio.Balance < 0)
                {
                    isOverdraft = true;
                }
            }


            return(isOverdraft);
        }
        public ActionResult Details(String id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            IRAccount irAccount = db.IRAccounts.Find(id);

            if (irAccount == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Balance             = GetValue(id);
            ViewBag.PendingTransactions = GetPendingTransactions(id);
            ViewBag.Transactions        = GetAllTransactions(id);
            return(View(irAccount));
        }
        public Decimal TotalContributions(Decimal transactionAmount)
        {
            AppUser   user        = db.Users.Find(User.Identity.GetUserId());
            IRAccount irAccount   = user.IRAccount;
            Decimal   sumDeposits = 0;

            foreach (var t in irAccount.Transactions)
            {
                if ((t.TransType == TransType.Deposit) ||
                    ((t.TransType == TransType.Transfer) && (t.ToAccount == irAccount.AccountNum)))
                {
                    sumDeposits = sumDeposits + (t.Amount);
                }
            }
            sumDeposits = sumDeposits + transactionAmount;

            return(sumDeposits);
        }
        public ActionResult CheckAccounts()
        {
            AppUser user = db.Users.Find(User.Identity.GetUserId());
            List <CheckingAccount> checkingAccounts = user.CheckingAccounts.ToList();
            List <SavingAccount>   savingAccounts   = user.SavingAccounts.ToList();
            IRAccount      irAccount      = user.IRAccount;
            StockPortfolio stockPortfolio = user.StockPortfolio;

            if (checkingAccounts.Count() == 0 && savingAccounts.Count() == 0 && irAccount == null && stockPortfolio == null)
            {
                return(RedirectToAction("ChooseAccount", "Account"));
            }

            else
            {
                return(RedirectToAction("Home"));
            }
        }
Example #16
0
        public static void SeedIRAccount(AppDbContext db, String[] account)
        {
            UserManager <AppUser> userManager = new UserManager <AppUser>(new UserStore <AppUser>(db));

            Int32   acctNum = Int32.Parse(account[0]);
            Decimal bal     = decimal.Parse(account[3]);

            var IRA = new IRAccount()
            {
                AccountNum  = acctNum,
                AccountName = account[2].ToString(),
                AppUser     = userManager.FindByEmail(account[1]),
                Balance     = bal
            };

            db.IRAccounts.AddOrUpdate(a => a.IRAccountID, IRA);
            db.SaveChanges();
        }
Example #17
0
        public ActionResult MaxContrib(MaxOptions SelectedMaxOption)
        {
            AppUser   user = db.Users.Find(User.Identity.GetUserId());
            IRAccount IRAccountToChange = user.IRAccount;

            switch (SelectedMaxOption)
            {
            case MaxOptions.Auto:
            {
                if (IRAccountToChange.MaxContribution == 0)
                {
                    return(View("ErrorAge", new string[] { "You cannot deposit. You have maxed on your contribution." }));
                }

                Transaction transaction = new Transaction();
                transaction.IRAccountAffected      = IRAccountToChange;
                transaction.Amount                 = IRAccountToChange.MaxContribution;
                transaction.TransactionType        = "Deposit";
                transaction.TransactionDate        = DateTime.Now;
                transaction.isBeingDisputed        = false;
                transaction.EmployeeComments       = "";
                transaction.Description            = "";
                transaction.isPending              = false;
                IRAccountToChange.Balance         += transaction.Amount;
                IRAccountToChange.MaxContribution -= transaction.Amount;
                IRAccountToChange.Transactions.Add(transaction);
                db.Transactions.Add(transaction);
                db.SaveChanges();
                return(RedirectToAction("MyBankAccounts", "Account"));
            }

            case MaxOptions.Input:
            {
                return(RedirectToAction("Deposit", "IRAccounts"));
            }

            case MaxOptions.Abandon:
            {
                return(RedirectToAction("MyBankAccounts", "Account"));
            }
            }

            return(RedirectToAction("MyBankAccounts", "Account"));
        }
Example #18
0
        // GET: IRAccount/Edit/5
        public ActionResult Edit(int?id)
        {
            AppUser customer = db.Users.Find(User.Identity.GetUserId());

            if (customer.IsActive)
            {
                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }
                IRAccount iRAccount = db.IRAccounts.Find(id);
                if (iRAccount == null)
                {
                    return(HttpNotFound());
                }
                return(View(iRAccount));
            }
            return(View("Error", new string[] { "Your account is inactive." }));
        }
Example #19
0
        //    return View(db.IRAccounts.ToList());
        //}


        ////search setup
        //public ActionResult Details(int? id, String DescriptionString, String SelectedType, PriceRange SelectedPrice, String PriceRangeTo, String PriceRangeFrom, String TransactionString, DateRange SelectedDate, String DateRangeTo, String DateRangeFrom)
        //{
        //    List<Transaction> TransactionList = new List<Transaction>();
        //    List<Transaction> SelectedTransaction = new List<Transaction>();

        //    //set up query
        //    var query = from t in db.Transactions
        //                select t;


        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            IRAccount iRAccount = db.IRAccounts.Find(id);

            if (iRAccount == null)
            {
                return(HttpNotFound());
            }
            IRAccountDetailsViewModel model = new IRAccountDetailsViewModel {
                IRAccountID = id, IRAccount = iRAccount, Transactions = iRAccount.Transactions
            };

            ViewBag.Count            = iRAccount.Transactions.Count();
            ViewBag.TransactionTypes = new SelectList(Utilities.Utility.TranscationTypes);
            return(View(model));
        }
        public ActionResult Create()
        {
            if (db.Users.Find(User.Identity.GetUserId()).Disabled == true)
            {
                return(Content("<script language'javascript' type = 'text/javascript'> alert('Access Denied: Your account has been disabled. You are in a view-only mode.'); window.location='../Customer/Home';</script>"));
            }

            AppUser user = db.Users.Find(User.Identity.GetUserId());

            if (user.IRAccount == null)
            {
                IRAccount ira = new IRAccount();
                ira.AccountName = "My IRA Account";
                return(View(ira));
            }
            else
            {
                return(Content("<script language'javascript' type = 'text/javascript'> alert('Error: You can only have one IRA.'); window.location='../Customer/Home';</script>"));
            }
        }
        public ActionResult ApproveTransaction(int?id)
        {
            Transaction transaction = db.Transactions.Find(id);

            if (transaction.CheckingAccountAffected != null)
            {
                EmailMessaging.SendEmail(transaction.CheckingAccountAffected.Customer.Email, "Transaction Approved", "The manager has approved your transaction. ");
                CheckingAccount CheckingAccountToAffect = transaction.CheckingAccountAffected;
                CheckingAccountToAffect.Balance += transaction.Amount;
                transaction.isPending            = false;
                db.SaveChanges();
                return(RedirectToAction("EmployeePortal", "Manage"));
            }
            else if (transaction.SavingsAccountAffected != null)
            {
                EmailMessaging.SendEmail(transaction.SavingsAccountAffected.Customer.Email, "Transaction Approved", "The manager has approved your transaction. ");
                SavingsAccount SavingsAccountToAffect = transaction.SavingsAccountAffected;
                SavingsAccountToAffect.Balance += transaction.Amount;
                transaction.isPending           = false;
                db.SaveChanges();
                return(RedirectToAction("EmployeePortal", "Manage"));
            }
            else if (transaction.IRAccountAffected != null)
            {
                EmailMessaging.SendEmail(transaction.IRAccountAffected.Customer.Email, "Transaction Approved", "The manager has approved your transaction. ");
                IRAccount IRAccountToAffect = transaction.IRAccountAffected;
                IRAccountToAffect.Balance += transaction.Amount;
                transaction.isPending      = false;
                db.SaveChanges();
                return(RedirectToAction("EmployeePortal", "Manage"));
            }
            else
            {
                EmailMessaging.SendEmail(transaction.StockPortfolioAffected.Customer.Email, "Transaction Approved", "The manager has approved your transaction. ");
                StockPortfolio StockPortfolioToAffect = transaction.StockPortfolioAffected;
                StockPortfolioToAffect.CashValueBalance += transaction.Amount;
                transaction.isPending = false;
                db.SaveChanges();
                return(RedirectToAction("EmployeePortal", "Manage"));
            }
        }
Example #22
0
        public ActionResult Deposit([Bind(Include = "TransactionID,TransactionDate,Amount,Description")] Transaction transaction, int IRAccountID)
        {
            //finding user
            AppUser user = db.Users.Find(User.Identity.GetUserId());

            if (ModelState.IsValid)
            {
                transaction.TransactionType  = "Deposit";
                transaction.isBeingDisputed  = false;
                transaction.EmployeeComments = "";
                IRAccount IRAccountToChange = db.IRAccounts.Find(IRAccountID);


                if (transaction.Amount > IRAccountToChange.MaxContribution)
                {
                    return(RedirectToAction("MaxContrib", "IRAccounts"));
                }
                else
                {
                    transaction.isPending              = false;
                    IRAccountToChange.Balance         += transaction.Amount;
                    IRAccountToChange.MaxContribution -= transaction.Amount;
                }
                if (transaction.Description == null)
                {
                    transaction.Description = "";
                }
                transaction.IRAccountAffected = IRAccountToChange;
                IRAccountToChange.Transactions.Add(transaction);
                db.Transactions.Add(transaction);
                db.SaveChanges();
                return(RedirectToAction("MyBankAccounts", "Account"));
            }
            //setting up viewbag so an IRAccount is chosen for sure
            ViewBag.iRAccounts = GetIRAccounts();
            return(View(transaction));
        }
        public Decimal GetValue(String id)
        {
            IRAccount irAccount = db.IRAccounts.Find(id);

            return(irAccount.Balance);
        }
Example #24
0
        public ActionResult Withdrawal([Bind(Include = "TransactionID,TransactionDate,Amount,Description")] Transaction transaction, FeeOptions SelectedFee, int IRAccountID)
        {
            if (ModelState.IsValid)
            {
                transaction.TransactionType  = "Withdrawal";
                transaction.isBeingDisputed  = false;
                transaction.EmployeeComments = "";
                transaction.isPending        = false;
                if (transaction.Description == null)
                {
                    transaction.Description = "";
                }
                IRAccount IRAAccountToChange = db.IRAccounts.Find(IRAccountID);
                if (IRAAccountToChange.Balance < 0)
                {
                    return(View("Error", new string[] { "You can't withdraw from an overdrawn account." }));
                }
                if (transaction.Amount > IRAAccountToChange.Balance)
                {
                    return(View("Error", new string[] { "You don't have enough funds to withdraw that much money." }));
                }
                if (IRAAccountToChange.isQualified == false)
                {
                    if (transaction.Amount > 3000)
                    {
                        return(View("Error", new string[] { "You cannot withdraw more than $3,000." }));
                    }


                    switch (SelectedFee)
                    {
                    case FeeOptions.IncludeFee:
                        IRAAccountToChange.Balance -= transaction.Amount;
                        transaction.Amount         -= 30;
                        Transaction transactionIncludeFee = new Transaction();
                        transactionIncludeFee.TransactionType   = "Fee";
                        transactionIncludeFee.TransactionDate   = DateTime.Now;
                        transactionIncludeFee.Amount            = 30;
                        transactionIncludeFee.isBeingDisputed   = false;
                        transactionIncludeFee.EmployeeComments  = "";
                        transactionIncludeFee.Description       = "";
                        transactionIncludeFee.isPending         = false;
                        transactionIncludeFee.IRAccountAffected = IRAAccountToChange;
                        IRAAccountToChange.Transactions.Add(transactionIncludeFee);
                        db.Transactions.Add(transactionIncludeFee);



                        transaction.IRAccountAffected = IRAAccountToChange;
                        IRAAccountToChange.Transactions.Add(transaction);
                        db.Transactions.Add(transaction);
                        db.SaveChanges();

                        break;

                    case FeeOptions.AdditionalFee:
                        IRAAccountToChange.Balance -= (transaction.Amount + 30);
                        Transaction transactionAddFee = new Transaction();
                        transactionAddFee.TransactionType   = "Fee";
                        transactionAddFee.TransactionDate   = DateTime.Now;
                        transactionAddFee.Amount            = 30;
                        transactionAddFee.isBeingDisputed   = false;
                        transactionAddFee.EmployeeComments  = "";
                        transactionAddFee.Description       = "";
                        transactionAddFee.isPending         = false;
                        transactionAddFee.IRAccountAffected = IRAAccountToChange;
                        IRAAccountToChange.Transactions.Add(transactionAddFee);
                        db.Transactions.Add(transactionAddFee);

                        transaction.IRAccountAffected = IRAAccountToChange;
                        IRAAccountToChange.Transactions.Add(transaction);
                        db.Transactions.Add(transaction);
                        db.SaveChanges();

                        break;
                    }

                    return(RedirectToAction("MyBankAccounts", "Account"));
                }
            }

            AppUser user = db.Users.Find(User.Identity.GetUserId());

            //setting up viewbag so an IRAccount is chosen for sure
            ViewBag.iRAccounts = GetIRAccounts();
            return(View(transaction));
        }
Example #25
0
        public ActionResult Details(IRAccountDetailsViewModel model, String TransactionNumber, String DateRange, String Description, String TransactionType, String PriceRange, String RangeFrom, String RangeTo, SortBy TransactionNumberSort, SortBy TransactionTypeSort, SortBy DescriptionSort, SortBy AmountSort, SortBy DateSort)
        {
            int?id = model.IRAccountID;

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            IRAccount iRAccount = db.IRAccounts.Find(id);
            IRAccountDetailsViewModel modelToPass = new IRAccountDetailsViewModel {
                IRAccountID = id, IRAccount = iRAccount, Transactions = iRAccount.Transactions
            };

            if (iRAccount == null)
            {
                return(HttpNotFound());
            }

            var query = from t in iRAccount.Transactions
                        select t;

            if (TransactionNumber != null && TransactionNumber != "")
            {
                Int32 number;
                try
                {
                    number = Convert.ToInt32(TransactionNumber);
                    query  = query.Where(t => t.TransactionID.Equals(number));
                }
                catch
                {
                    ViewBag.TransactionNumberValidation = "Enter a whole number";
                    ViewBag.Count            = iRAccount.Transactions.Count();
                    ViewBag.TransactionTypes = new SelectList(Utilities.Utility.TranscationTypes);
                    return(View(modelToPass));
                }
            }
            query = query.Where(t => t.Description.Contains(Description));
            if (!DateRange.Equals("Custom") && !DateRange.Equals("All"))
            {
                if (DateRange.Equals("Last 15 days"))
                {
                    query = query.Where(t => t.TransactionDate >= DateTime.Now.AddDays(-1));
                }
                else if (DateRange.Equals("Last 30 days"))
                {
                    query = query.Where(t => t.TransactionDate >= DateTime.Now.AddDays(-30));
                }
                else
                {
                    query = query.Where(t => t.TransactionDate >= DateTime.Now.AddDays(-60));
                }
            }
            if (DateRange.Equals("Custom"))
            {
                query = query.Where(t => t.TransactionDate >= model.DateFrom && t.TransactionDate <= model.DateTo);
            }
            if (!TransactionType.Equals("All"))
            {
                query = query.Where(t => t.TransactionType.Equals(TransactionType));
            }
            if (!PriceRange.Equals("Custom"))
            {
                if (PriceRange.Equals("$0-$100"))
                {
                    query = query.Where(t => t.Amount >= 0 && t.Amount <= 100);
                }
                else if (PriceRange.Equals("$100-$200"))
                {
                    query = query.Where(t => t.Amount >= 100 && t.Amount <= 200);
                }
                else if (PriceRange.Equals("$200-$300"))
                {
                    query = query.Where(t => t.Amount >= 200 && t.Amount <= 300);
                }
                else
                {
                    query = query.Where(t => t.Amount >= 300);
                }
            }
            else
            {
                Decimal rangeFrom;
                Decimal rangeTo;
                try
                {
                    rangeFrom = Convert.ToDecimal(RangeFrom);
                    rangeTo   = Convert.ToDecimal(RangeTo);
                    query     = query.Where(t => t.Amount >= rangeFrom && t.Amount <= rangeTo);
                }
                catch
                {
                    ViewBag.Message          = "Enter a valid range of numbers";
                    ViewBag.Count            = iRAccount.Transactions.Count();
                    ViewBag.TransactionTypes = new SelectList(Utilities.Utility.TranscationTypes);
                    return(View(modelToPass));
                }
            }

            if (TransactionNumberSort.Equals(SortBy.Ascending))
            {
                if (TransactionTypeSort.Equals(SortBy.Ascending))
                {
                    if (DescriptionSort.Equals(SortBy.Ascending))
                    {
                        if (AmountSort.Equals(SortBy.Ascending))
                        {
                            if (DateSort.Equals(SortBy.Ascending))
                            {
                                query.OrderBy(t => t.TransactionID).ThenBy(t => t.TransactionType).ThenBy(t => t.Description).ThenBy(t => t.Amount).ThenBy(t => t.TransactionDate);
                            }
                            else
                            {
                                query.OrderBy(t => t.TransactionID).ThenBy(t => t.TransactionType).ThenBy(t => t.Description).ThenBy(t => t.Amount).ThenByDescending(t => t.TransactionDate);
                            }
                        }
                        else
                        {
                            if (DateSort.Equals(SortBy.Ascending))
                            {
                                query.OrderBy(t => t.TransactionID).ThenBy(t => t.TransactionType).ThenBy(t => t.Description).ThenByDescending(t => t.Amount).ThenBy(t => t.TransactionDate);
                            }
                            else
                            {
                                query.OrderBy(t => t.TransactionID).ThenBy(t => t.TransactionType).ThenBy(t => t.Description).ThenByDescending(t => t.Amount).ThenByDescending(t => t.TransactionDate);
                            }
                        }
                    }
                    else
                    {
                        if (AmountSort.Equals(SortBy.Ascending))
                        {
                            if (DateSort.Equals(SortBy.Ascending))
                            {
                                query.OrderBy(t => t.TransactionID).ThenBy(t => t.TransactionType).ThenByDescending(t => t.Description).ThenBy(t => t.Amount).ThenBy(t => t.TransactionDate);
                            }
                            else
                            {
                                query.OrderBy(t => t.TransactionID).ThenBy(t => t.TransactionType).ThenByDescending(t => t.Description).ThenBy(t => t.Amount).ThenByDescending(t => t.TransactionDate);
                            }
                        }
                        else
                        {
                            if (DateSort.Equals(SortBy.Ascending))
                            {
                                query.OrderBy(t => t.TransactionID).ThenBy(t => t.TransactionType).ThenByDescending(t => t.Description).ThenByDescending(t => t.Amount).ThenBy(t => t.TransactionDate);
                            }
                            else
                            {
                                query.OrderBy(t => t.TransactionID).ThenBy(t => t.TransactionType).ThenByDescending(t => t.Description).ThenByDescending(t => t.Amount).ThenByDescending(t => t.TransactionDate);
                            }
                        }
                    }
                }
                else
                {
                    if (DescriptionSort.Equals(SortBy.Ascending))
                    {
                        if (AmountSort.Equals(SortBy.Ascending))
                        {
                            if (DateSort.Equals(SortBy.Ascending))
                            {
                                query.OrderBy(t => t.TransactionID).ThenByDescending(t => t.TransactionType).ThenBy(t => t.Description).ThenBy(t => t.Amount).ThenBy(t => t.TransactionDate);
                            }
                            else
                            {
                                query.OrderBy(t => t.TransactionID).ThenByDescending(t => t.TransactionType).ThenBy(t => t.Description).ThenBy(t => t.Amount).ThenByDescending(t => t.TransactionDate);
                            }
                        }
                        else
                        {
                            if (DateSort.Equals(SortBy.Ascending))
                            {
                                query.OrderBy(t => t.TransactionID).ThenByDescending(t => t.TransactionType).ThenBy(t => t.Description).ThenByDescending(t => t.Amount).ThenBy(t => t.TransactionDate);
                            }
                            else
                            {
                                query.OrderBy(t => t.TransactionID).ThenByDescending(t => t.TransactionType).ThenBy(t => t.Description).ThenByDescending(t => t.Amount).ThenByDescending(t => t.TransactionDate);
                            }
                        }
                    }
                    else
                    {
                        if (AmountSort.Equals(SortBy.Ascending))
                        {
                            if (DateSort.Equals(SortBy.Ascending))
                            {
                                query.OrderBy(t => t.TransactionID).ThenByDescending(t => t.TransactionType).ThenByDescending(t => t.Description).ThenBy(t => t.Amount).ThenBy(t => t.TransactionDate);
                            }
                            else
                            {
                                query.OrderBy(t => t.TransactionID).ThenByDescending(t => t.TransactionType).ThenByDescending(t => t.Description).ThenBy(t => t.Amount).ThenByDescending(t => t.TransactionDate);
                            }
                        }
                        else
                        {
                            if (DateSort.Equals(SortBy.Ascending))
                            {
                                query.OrderBy(t => t.TransactionID).ThenByDescending(t => t.TransactionType).ThenByDescending(t => t.Description).ThenByDescending(t => t.Amount).ThenBy(t => t.TransactionDate);
                            }
                            else
                            {
                                query.OrderBy(t => t.TransactionID).ThenByDescending(t => t.TransactionType).ThenByDescending(t => t.Description).ThenByDescending(t => t.Amount).ThenByDescending(t => t.TransactionDate);
                            }
                        }
                    }
                }
            }
            else
            {
                if (TransactionTypeSort.Equals(SortBy.Ascending))
                {
                    if (DescriptionSort.Equals(SortBy.Ascending))
                    {
                        if (AmountSort.Equals(SortBy.Ascending))
                        {
                            if (DateSort.Equals(SortBy.Ascending))
                            {
                                query.OrderByDescending(t => t.TransactionID).ThenBy(t => t.TransactionType).ThenBy(t => t.Description).ThenBy(t => t.Amount).ThenBy(t => t.TransactionDate);
                            }
                            else
                            {
                                query.OrderByDescending(t => t.TransactionID).ThenBy(t => t.TransactionType).ThenBy(t => t.Description).ThenBy(t => t.Amount).ThenByDescending(t => t.TransactionDate);
                            }
                        }
                        else
                        {
                            if (DateSort.Equals(SortBy.Ascending))
                            {
                                query.OrderByDescending(t => t.TransactionID).ThenBy(t => t.TransactionType).ThenBy(t => t.Description).ThenByDescending(t => t.Amount).ThenBy(t => t.TransactionDate);
                            }
                            else
                            {
                                query.OrderByDescending(t => t.TransactionID).ThenBy(t => t.TransactionType).ThenBy(t => t.Description).ThenByDescending(t => t.Amount).ThenByDescending(t => t.TransactionDate);
                            }
                        }
                    }
                    else
                    {
                        if (AmountSort.Equals(SortBy.Ascending))
                        {
                            if (DateSort.Equals(SortBy.Ascending))
                            {
                                query.OrderByDescending(t => t.TransactionID).ThenBy(t => t.TransactionType).ThenByDescending(t => t.Description).ThenBy(t => t.Amount).ThenBy(t => t.TransactionDate);
                            }
                            else
                            {
                                query.OrderByDescending(t => t.TransactionID).ThenBy(t => t.TransactionType).ThenByDescending(t => t.Description).ThenBy(t => t.Amount).ThenByDescending(t => t.TransactionDate);
                            }
                        }
                        else
                        {
                            if (DateSort.Equals(SortBy.Ascending))
                            {
                                query.OrderByDescending(t => t.TransactionID).ThenBy(t => t.TransactionType).ThenByDescending(t => t.Description).ThenByDescending(t => t.Amount).ThenBy(t => t.TransactionDate);
                            }
                            else
                            {
                                query.OrderByDescending(t => t.TransactionID).ThenBy(t => t.TransactionType).ThenByDescending(t => t.Description).ThenByDescending(t => t.Amount).ThenByDescending(t => t.TransactionDate);
                            }
                        }
                    }
                }
                else
                {
                    if (DescriptionSort.Equals(SortBy.Ascending))
                    {
                        if (AmountSort.Equals(SortBy.Ascending))
                        {
                            if (DateSort.Equals(SortBy.Ascending))
                            {
                                query.OrderByDescending(t => t.TransactionID).ThenByDescending(t => t.TransactionType).ThenBy(t => t.Description).ThenBy(t => t.Amount).ThenBy(t => t.TransactionDate);
                            }
                            else
                            {
                                query.OrderByDescending(t => t.TransactionID).ThenByDescending(t => t.TransactionType).ThenBy(t => t.Description).ThenBy(t => t.Amount).ThenByDescending(t => t.TransactionDate);
                            }
                        }
                        else
                        {
                            if (DateSort.Equals(SortBy.Ascending))
                            {
                                query.OrderByDescending(t => t.TransactionID).ThenByDescending(t => t.TransactionType).ThenBy(t => t.Description).ThenByDescending(t => t.Amount).ThenBy(t => t.TransactionDate);
                            }
                            else
                            {
                                query.OrderByDescending(t => t.TransactionID).ThenByDescending(t => t.TransactionType).ThenBy(t => t.Description).ThenByDescending(t => t.Amount).ThenByDescending(t => t.TransactionDate);
                            }
                        }
                    }
                    else
                    {
                        if (AmountSort.Equals(SortBy.Ascending))
                        {
                            if (DateSort.Equals(SortBy.Ascending))
                            {
                                query.OrderByDescending(t => t.TransactionID).ThenByDescending(t => t.TransactionType).ThenByDescending(t => t.Description).ThenBy(t => t.Amount).ThenBy(t => t.TransactionDate);
                            }
                            else
                            {
                                query.OrderByDescending(t => t.TransactionID).ThenByDescending(t => t.TransactionType).ThenByDescending(t => t.Description).ThenBy(t => t.Amount).ThenByDescending(t => t.TransactionDate);
                            }
                        }
                        else
                        {
                            if (DateSort.Equals(SortBy.Ascending))
                            {
                                query.OrderByDescending(t => t.TransactionID).ThenByDescending(t => t.TransactionType).ThenByDescending(t => t.Description).ThenByDescending(t => t.Amount).ThenBy(t => t.TransactionDate);
                            }
                            else
                            {
                                query.OrderByDescending(t => t.TransactionID).ThenByDescending(t => t.TransactionType).ThenByDescending(t => t.Description).ThenByDescending(t => t.Amount).ThenByDescending(t => t.TransactionDate);
                            }
                        }
                    }
                }
            }

            query.OrderByDescending(t => t.TransactionID);
            List <Transaction> list = query.ToList();

            modelToPass = new IRAccountDetailsViewModel {
                IRAccountID = id, IRAccount = iRAccount, Transactions = list
            };
            ViewBag.Count            = list.Count();
            ViewBag.TransactionTypes = new SelectList(Utilities.Utility.TranscationTypes);
            return(View(modelToPass));
        }
        public ActionResult Create([Bind(Include = "TransactionID,TransactionNum,Date,FromAccount,ToAccount,TransType,Amount,Description")] Transaction transaction, int?toAccount)
        {
            if (toAccount != null)
            {
                transaction.ToAccount = toAccount;
            }

            if (ModelState.IsValid)
            {
                Int32? accountNum  = transaction.ToAccount;
                String accountType = GetAccountType(transaction.ToAccount);
                transaction.TransType   = TransType.Deposit;
                transaction.Description = "Deposit $" + transaction.Amount.ToString() + " into " + accountNum.ToString().Substring(accountNum.ToString().Length - 4);

                if (accountType == "CHECKING")
                {
                    var query = from a in db.CheckingAccounts
                                where a.AccountNum == accountNum
                                select a.CheckingAccountID;
                    //gets first (only) thing from query list
                    Int32           accountID = query.First();
                    CheckingAccount account   = db.CheckingAccounts.Find(accountID);
                    account.Transactions.Add(transaction);
                    //Add the deposit to the account if it's less than 5000
                    //Otherwise, mark it for approval from a manager
                    if (transaction.Amount <= 0)
                    {
                        return(Content("<script language'javascript' type = 'text/javascript'> alert('Error: You cannot deposit a negative amount.'); window.location='../Deposit/Create';</script>"));
                    }
                    if (transaction.Amount >= 5000)
                    {
                        transaction.NeedsApproval = true;
                    }
                    else
                    {
                        account.Balance = account.Balance + transaction.Amount;
                    }
                }

                else if (accountType == "SAVING")
                {
                    var query = from a in db.SavingAccounts
                                where a.AccountNum == accountNum
                                select a.SavingAccountID;
                    //gets first (only) thing from query list
                    Int32         accountID = query.First();
                    SavingAccount account   = db.SavingAccounts.Find(accountID);
                    account.Transactions.Add(transaction);
                    //Check if transaction needs approval
                    if (transaction.Amount <= 0)
                    {
                        return(Content("<script language'javascript' type = 'text/javascript'> alert('Error: You cannot deposit a negative amount.'); window.location='../Deposit/Create';</script>"));
                    }
                    if (transaction.Amount >= 5000)
                    {
                        transaction.NeedsApproval = true;
                    }
                    else
                    {
                        account.Balance = account.Balance + transaction.Amount;
                    }
                }

                else if (accountType == "IRA")
                {
                    var query = from a in db.IRAccounts
                                where a.AccountNum == accountNum
                                select a.IRAccountID;
                    //gets first (only) thing from query list
                    String    accountID = query.First();
                    IRAccount account   = db.IRAccounts.Find(accountID);

                    //if user is over 70, they cannot deposit
                    if (transaction.Amount <= 0)
                    {
                        return(Content("<script language'javascript' type = 'text/javascript'> alert('Error: You cannot deposit a negative amount.'); window.location='../Deposit/Create';</script>"));
                    }
                    if (UnderAgeLimt() == false)
                    {
                        return(Content("<script language'javascript' type = 'text/javascript'> alert('Error: You cannot deposit if you are over 70 years old.'); window.location='../Customer/Home';</script>"));
                    }

                    //if total contributions > 5000, they cannot deposit this amount
                    Decimal iraContributionTotal = TotalContributions(transaction.Amount);
                    if (iraContributionTotal > 5000)
                    {
                        Decimal maxDepositAmount = 5000 - (iraContributionTotal - transaction.Amount);

                        if (maxDepositAmount > 0)
                        {
                            transaction.Amount = maxDepositAmount;
                            ModelState.Clear();
                            return(View("CreateAutoCorrect", transaction));
                        }
                        else
                        {
                            return(Content("<script language'javascript' type = 'text/javascript'> alert('Error: You have reached your max contribution amount of $5000. You cannot contribute to your IRA any more this year.'); window.location='../Customer/Home';</script>"));
                        }
                    }

                    account.Transactions.Add(transaction);
                    account.Balance = account.Balance + transaction.Amount;
                }

                else if (accountType == "STOCKPORTFOLIO")
                {
                    var query = from a in db.StockPortfolios
                                where a.AccountNum == accountNum
                                select a.StockPortfolioID;
                    //gets first (only) thing from query list
                    String         accountID = query.First();
                    StockPortfolio account   = db.StockPortfolios.Find(accountID);
                    account.Transactions.Add(transaction);
                    if (transaction.Amount <= 0)
                    {
                        return(Content("<script language'javascript' type = 'text/javascript'> alert('Error: You cannot deposit a negative amount.'); window.location='../Deposit/Create';</script>"));
                    }
                    if (transaction.Amount >= 5000)
                    {
                        transaction.NeedsApproval = true;
                    }
                    else
                    {
                        account.Balance = account.Balance + transaction.Amount;
                    }
                }

                db.SaveChanges();

                if (transaction.NeedsApproval == true)
                {
                    return(Content("<script language'javascript' type = 'text/javascript'> alert('Confirmation: Deposit over $5000.00, pending manager approval'); window.location='../Customer/Home';</script>"));
                }
                else
                {
                    return(Content("<script language'javascript' type = 'text/javascript'> alert('Confirmation: Deposit successfull!'); window.location='../Customer/Home';</script>"));
                }
            }

            List <AccountsViewModel> allAccounts = GetAccounts();
            SelectList selectAccounts            = new SelectList(allAccounts.OrderBy(q => q.AccountName), "AccountNum", "AccountName");

            ViewBag.allAccounts = selectAccounts;
            return(View(transaction));
        }
        // GET: Transactions/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Transaction transaction = db.Transactions.Find(id);

            if (transaction == null)
            {
                return(HttpNotFound());
            }
            if (transaction.CheckingAccountAffected != null)
            {
                CheckingAccount checkingAccount = transaction.CheckingAccountAffected;
                var             query           = from t in checkingAccount.Transactions
                                                  where t.TransactionType.Equals(transaction.TransactionType)
                                                  select t;
                query.OrderBy(t => t.TransactionDate);
                List <Transaction> prelist = query.ToList();
                List <Transaction> list    = new List <Transaction>();
                if (prelist.Count() == 1)
                {
                    list.Add(prelist[0]);
                }
                else if (prelist.Count() == 2)
                {
                    list.Add(prelist[0]); list.Add(prelist[1]);
                }
                else if (prelist.Count() == 3)
                {
                    list.Add(prelist[0]); list.Add(prelist[1]); list.Add(prelist[2]);
                }
                else if (prelist.Count() == 4)
                {
                    list.Add(prelist[0]); list.Add(prelist[1]); list.Add(prelist[2]); list.Add(prelist[3]);
                }
                else
                {
                    list.Add(prelist[0]); list.Add(prelist[1]); list.Add(prelist[2]); list.Add(prelist[3]); list.Add(prelist[4]);
                }
                TransactionsDetailsViewModel model = new TransactionsDetailsViewModel {
                    TransactionID = id, Transaction = transaction, FiveTransactions = list
                };
                return(View(model));
            }
            else if (transaction.SavingsAccountAffected != null)
            {
                SavingsAccount savingsAccount = transaction.SavingsAccountAffected;
                var            query          = from t in savingsAccount.Transactions
                                                where t.TransactionType.Equals(transaction.TransactionType)
                                                select t;
                query.OrderBy(t => t.TransactionDate);
                List <Transaction> prelist = query.ToList();
                List <Transaction> list    = new List <Transaction>();
                if (prelist.Count() == 1)
                {
                    list.Add(prelist[0]);
                }
                else if (prelist.Count() == 2)
                {
                    list.Add(prelist[0]); list.Add(prelist[1]);
                }
                else if (prelist.Count() == 3)
                {
                    list.Add(prelist[0]); list.Add(prelist[1]); list.Add(prelist[2]);
                }
                else if (prelist.Count() == 4)
                {
                    list.Add(prelist[0]); list.Add(prelist[1]); list.Add(prelist[2]); list.Add(prelist[3]);
                }
                else
                {
                    list.Add(prelist[0]); list.Add(prelist[1]); list.Add(prelist[2]); list.Add(prelist[3]); list.Add(prelist[4]);
                }
                TransactionsDetailsViewModel model = new TransactionsDetailsViewModel {
                    TransactionID = id, Transaction = transaction, FiveTransactions = list
                };
                return(View(model));
            }
            else if (transaction.IRAccountAffected != null)
            {
                IRAccount iRAccount = transaction.IRAccountAffected;
                var       query     = from t in iRAccount.Transactions
                                      where t.TransactionType.Equals(transaction.TransactionType)
                                      select t;
                query.OrderBy(t => t.TransactionDate);
                List <Transaction> prelist = query.ToList();
                List <Transaction> list    = new List <Transaction>();
                if (prelist.Count() == 1)
                {
                    list.Add(prelist[0]);
                }
                else if (prelist.Count() == 2)
                {
                    list.Add(prelist[0]); list.Add(prelist[1]);
                }
                else if (prelist.Count() == 3)
                {
                    list.Add(prelist[0]); list.Add(prelist[1]); list.Add(prelist[2]);
                }
                else if (prelist.Count() == 4)
                {
                    list.Add(prelist[0]); list.Add(prelist[1]); list.Add(prelist[2]); list.Add(prelist[3]);
                }
                else
                {
                    list.Add(prelist[0]); list.Add(prelist[1]); list.Add(prelist[2]); list.Add(prelist[3]); list.Add(prelist[4]);
                }
                TransactionsDetailsViewModel model = new TransactionsDetailsViewModel {
                    TransactionID = id, Transaction = transaction, FiveTransactions = list
                };
                return(View(model));
            }
            else
            {
                StockPortfolio stockPortfolio = transaction.StockPortfolioAffected;
                var            query          = from t in stockPortfolio.Transactions
                                                where t.TransactionType.Equals(transaction.TransactionType)
                                                select t;
                query.OrderBy(t => t.TransactionDate);
                List <Transaction> prelist = query.ToList();
                List <Transaction> list    = new List <Transaction>();
                if (prelist.Count() == 1)
                {
                    list.Add(prelist[0]);
                }
                else if (prelist.Count() == 2)
                {
                    list.Add(prelist[0]); list.Add(prelist[1]);
                }
                else if (prelist.Count() == 3)
                {
                    list.Add(prelist[0]); list.Add(prelist[1]); list.Add(prelist[2]);
                }
                else if (prelist.Count() == 4)
                {
                    list.Add(prelist[0]); list.Add(prelist[1]); list.Add(prelist[2]); list.Add(prelist[3]);
                }
                else
                {
                    list.Add(prelist[0]); list.Add(prelist[1]); list.Add(prelist[2]); list.Add(prelist[3]); list.Add(prelist[4]);
                }
                TransactionsDetailsViewModel model = new TransactionsDetailsViewModel {
                    TransactionID = id, Transaction = transaction, FiveTransactions = list
                };
                return(View(model));
            }
        }
Example #28
0
        public ActionResult Create([Bind(Include = "IRAccountID,Balance")] IRAccount iRAccount)
        {
            AppUser user = db.Users.Find(User.Identity.GetUserId());

            iRAccount.Customer = user;


            if (user.IRAccount != null)
            {
                return(View("Error", new string[] { "You have already created an IRAccount." }));
            }

            else
            {
                if (ModelState.IsValid)
                {
                    iRAccount.AccountNumber = Utility.AccountNumber;
                    Utility.AccountNumber  += 1;

                    iRAccount.AccountName = "Longhorn IRA";

                    iRAccount.MaxContribution = 5000;


                    iRAccount.Customer.HasAccount = true;


                    Transaction transaction = new Transaction();
                    transaction.IRAccountAffected = iRAccount;
                    transaction.TransactionType   = "Deposit";
                    transaction.TransactionDate   = DateTime.Now;
                    transaction.Amount            = iRAccount.Balance;
                    iRAccount.MaxContribution    -= transaction.Amount;
                    transaction.Description       = "Initial Deposit into " + iRAccount.AccountNumber;
                    transaction.isBeingDisputed   = false;
                    transaction.EmployeeComments  = "";
                    if (iRAccount.Balance > 5000)
                    {
                        transaction.isPending = true;
                        iRAccount.Balance     = 0;
                    }
                    else
                    {
                        transaction.isPending = false;
                    }



                    DateTime now = DateTime.Today;
                    int      age = now.Year - user.DOB.Year;
                    if (age > 65)
                    {
                        iRAccount.isQualified = true;
                    }


                    iRAccount.isQualified = false;

                    db.Transactions.Add(transaction);
                    iRAccount.Transactions = new List <Transaction>();
                    iRAccount.Transactions.Add(transaction);
                    db.IRAccounts.Add(iRAccount);
                    db.SaveChanges();
                    return(RedirectToAction("BankAccountCreatedConfirmation", "Account"));
                }
            }

            return(View(iRAccount));
        }
Example #29
0
        public ActionResult AdjustDispute(int?id)
        {
            Transaction transaction = db.Transactions.Find(id);

            if (transaction.CheckingAccountAffected != null)
            {
                EmailMessaging.SendEmail(transaction.CheckingAccountAffected.Customer.Email, "Dispute Adjusted", "The manager has adjusted your dispute. ");
                if (transaction.TransactionType == "Withdrawal" || transaction.TransactionType == "Bill Payment" || transaction.TransactionType == "Fee")
                {
                    transaction.CheckingAccountAffected.Balance += transaction.Amount;
                    transaction.CheckingAccountAffected.Balance -= transaction.Dispute.CorrectAmount;
                    transaction.Amount = transaction.Dispute.CorrectAmount;
                    transaction.Dispute.CurrentStatus = "Accepted";
                    db.SaveChanges();
                    return(RedirectToAction("ResolveDisputeConfirmation"));
                }
                else if (transaction.TransactionType == "Deposit" || transaction.TransactionType == "Bonus")
                {
                    transaction.CheckingAccountAffected.Balance -= transaction.Amount;
                    transaction.CheckingAccountAffected.Balance += transaction.Dispute.CorrectAmount;
                    transaction.Amount = transaction.Dispute.CorrectAmount;
                    transaction.Dispute.CurrentStatus = "Accepted";
                    db.SaveChanges();
                    return(RedirectToAction("ResolveDisputeConfirmation"));
                }
            }
            else if (transaction.SavingsAccountAffected != null)
            {
                EmailMessaging.SendEmail(transaction.SavingsAccountAffected.Customer.Email, "Dispute Adjusted", "The manager has adjusted your dispute. ");
                if (transaction.TransactionType == "Withdrawal" || transaction.TransactionType == "Bill Payment" || transaction.TransactionType == "Fee")
                {
                    transaction.SavingsAccountAffected.Balance += transaction.Amount;
                    transaction.SavingsAccountAffected.Balance -= transaction.Dispute.CorrectAmount;
                    transaction.Amount = transaction.Dispute.CorrectAmount;
                    transaction.Dispute.CurrentStatus = "Accepted";
                    db.SaveChanges();
                    return(RedirectToAction("ResolveDisputeConfirmation"));
                }
                else if (transaction.TransactionType == "Deposit" || transaction.TransactionType == "Bonus")
                {
                    transaction.SavingsAccountAffected.Balance -= transaction.Amount;
                    transaction.SavingsAccountAffected.Balance += transaction.Dispute.CorrectAmount;
                    transaction.Amount = transaction.Dispute.CorrectAmount;
                    transaction.Dispute.CurrentStatus = "Accepted";
                    db.SaveChanges();
                    return(RedirectToAction("ResolveDisputeConfirmation"));
                }
            }
            else if (transaction.IRAccountAffected != null)
            {
                EmailMessaging.SendEmail(transaction.IRAccountAffected.Customer.Email, "Dispute Adjusted", "The manager has adjusted your dispute. ");
                if (transaction.TransactionType == "Withdrawal" || transaction.TransactionType == "Bill Payment" || transaction.TransactionType == "Fee")
                {
                    transaction.IRAccountAffected.Balance += transaction.Amount;
                    transaction.IRAccountAffected.Balance -= transaction.Dispute.CorrectAmount;
                    transaction.Amount = transaction.Dispute.CorrectAmount;
                    transaction.Dispute.CurrentStatus = "Accepted";
                    db.SaveChanges();
                    return(RedirectToAction("ResolveDisputeConfirmation"));
                }
                else if (transaction.TransactionType == "Deposit" || transaction.TransactionType == "Bonus")
                {
                    transaction.IRAccountAffected.Balance -= transaction.Amount;
                    transaction.IRAccountAffected.Balance += transaction.Dispute.CorrectAmount;
                    transaction.Amount = transaction.Dispute.CorrectAmount;
                    transaction.Dispute.CurrentStatus = "Accepted";
                    db.SaveChanges();
                    return(RedirectToAction("ResolveDisputeConfirmation"));
                }
            }
            else if (transaction.StockPortfolioAffected != null)
            {
                EmailMessaging.SendEmail(transaction.StockPortfolioAffected.Customer.Email, "Dispute Adjusted", "The manager has adjusted your dispute. ");

                if (transaction.TransactionType == "Withdrawal" || transaction.TransactionType == "Bill Payment" || transaction.TransactionType == "Fee")
                {
                    transaction.StockPortfolioAffected.CashValueBalance += transaction.Amount;
                    transaction.StockPortfolioAffected.CashValueBalance -= transaction.Dispute.CorrectAmount;
                    transaction.Amount = transaction.Dispute.CorrectAmount;
                    transaction.Dispute.CurrentStatus = "Accepted";
                    db.SaveChanges();
                    return(RedirectToAction("ResolveDisputeConfirmation"));
                }
                else if (transaction.TransactionType == "Deposit" || transaction.TransactionType == "Bonus")
                {
                    transaction.StockPortfolioAffected.CashValueBalance -= transaction.Amount;
                    transaction.StockPortfolioAffected.CashValueBalance += transaction.Dispute.CorrectAmount;
                    transaction.Amount = transaction.Dispute.CorrectAmount;
                    transaction.Dispute.CurrentStatus = "Accepted";
                    db.SaveChanges();
                    return(RedirectToAction("ResolveDisputeConfirmation"));
                }
            }
            else if (transaction.TransferToCheckingAccount != null)
            {
                EmailMessaging.SendEmail(transaction.CheckingAccountAffected.Customer.Email, "Dispute Adjusted", "The manager has adjusted your dispute. ");
                CheckingAccount CheckingAccountToAffect = transaction.TransferToCheckingAccount;
                CheckingAccountToAffect.Balance -= transaction.Amount;
                CheckingAccountToAffect.Balance += transaction.Dispute.CorrectAmount;
                transaction.Amount = transaction.Dispute.CorrectAmount;
                transaction.Dispute.CurrentStatus = "Accepted";
                db.SaveChanges();
                return(RedirectToAction("ResolveDisputeConfirmed"));
            }
            else if (transaction.TransferFromCheckingAccount != null)
            {
                CheckingAccount CheckingAccountToAffect = transaction.TransferFromCheckingAccount;
                CheckingAccountToAffect.Balance += transaction.Amount;
                CheckingAccountToAffect.Balance -= transaction.Dispute.CorrectAmount;
                transaction.Amount = transaction.Dispute.CorrectAmount;
                transaction.Dispute.CurrentStatus = "Accepted";
                db.SaveChanges();
                return(RedirectToAction("ResolveDisputeConfirmed"));
            }
            else if (transaction.TransferToSavingsAccount != null)
            {
                SavingsAccount SavingsAccountToAffect = transaction.TransferToSavingsAccount;
                SavingsAccountToAffect.Balance   -= transaction.Amount;
                SavingsAccountToAffect.Balance   += transaction.Dispute.CorrectAmount;
                transaction.Amount                = transaction.Dispute.CorrectAmount;
                transaction.Dispute.CurrentStatus = "Accepted";
                db.SaveChanges();
                return(RedirectToAction("ResolveDisputeConfirmed"));
            }
            else if (transaction.TransferFromSavingsAccount != null)
            {
                SavingsAccount SavingsAccountToAffect = transaction.TransferFromSavingsAccount;
                SavingsAccountToAffect.Balance   += transaction.Amount;
                SavingsAccountToAffect.Balance   -= transaction.Dispute.CorrectAmount;
                transaction.Amount                = transaction.Dispute.CorrectAmount;
                transaction.Dispute.CurrentStatus = "Accepted";
                db.SaveChanges();
                return(RedirectToAction("ResolveDisputeConfirmed"));
            }
            else if (transaction.TransferToIRAccount != null)
            {
                IRAccount IRAccountToAffect = transaction.TransferToIRAccount;
                IRAccountToAffect.Balance        -= transaction.Amount;
                IRAccountToAffect.Balance        += transaction.Dispute.CorrectAmount;
                transaction.Amount                = transaction.Dispute.CorrectAmount;
                transaction.Dispute.CurrentStatus = "Accepted";
                db.SaveChanges();
                return(RedirectToAction("ResolveDisputeConfirmed"));
            }
            else if (transaction.TransferFromIRAccount != null)
            {
                IRAccount IRAccountToAffect = transaction.TransferFromIRAccount;
                IRAccountToAffect.Balance        += transaction.Amount;
                IRAccountToAffect.Balance        -= transaction.Dispute.CorrectAmount;
                transaction.Amount                = transaction.Dispute.CorrectAmount;
                transaction.Dispute.CurrentStatus = "Accepted";
                db.SaveChanges();
                return(RedirectToAction("ResolveDisputeConfirmed"));
            }
            else if (transaction.TransferFromStockPortfolio != null)
            {
                StockPortfolio StockPortfolioToAffect = transaction.TransferFromStockPortfolio;
                StockPortfolioToAffect.CashValueBalance += transaction.Amount;
                StockPortfolioToAffect.CashValueBalance -= transaction.Dispute.CorrectAmount;
                transaction.Amount = transaction.Dispute.CorrectAmount;
                transaction.Dispute.CurrentStatus = "Accepted";
                db.SaveChanges();
                return(RedirectToAction("ResolveDisputeConfirmed"));
            }
            else if (transaction.TransferToStockPortfolio != null)
            {
                StockPortfolio StockPortfolioToAffect = transaction.TransferToStockPortfolio;
                StockPortfolioToAffect.CashValueBalance -= transaction.Amount;
                StockPortfolioToAffect.CashValueBalance += transaction.Dispute.CorrectAmount;
                transaction.Amount = transaction.Dispute.CorrectAmount;
                transaction.Dispute.CurrentStatus = "Accepted";
                db.SaveChanges();
                return(RedirectToAction("ResolveDisputeConfirmed"));
            }

            return(RedirectToAction("EmployeePortal", "Manage"));
        }
        public ActionResult Create([Bind(Include = "TransactionID,TransactionNum,Date,FromAccount,ToAccount,TransType,Amount,Description")] Transaction transaction, int?toAccount1, int?fromAccount1)
        {
            if (fromAccount1 != null)
            {
                transaction.FromAccount = fromAccount1;
            }
            if (toAccount1 != null)
            {
                transaction.ToAccount = toAccount1;
            }


            if (ModelState.IsValid)
            {
                Int32? fromAccountNum  = transaction.FromAccount;
                Int32? toAccountNum    = transaction.ToAccount;
                String fromAccountType = GetAccountType(fromAccountNum);
                String toAccountType   = GetAccountType(toAccountNum);
                transaction.TransType   = TransType.Transfer;
                transaction.Description = "Transfer $" + transaction.Amount.ToString() + " from " + transaction.FromAccount.ToString().Substring(transaction.FromAccount.ToString().Length - 4) + " to " + transaction.ToAccount.ToString().Substring(transaction.ToAccount.ToString().Length - 4);

                if (toAccountType == "CHECKING")
                {
                    var query = from a in db.CheckingAccounts
                                where a.AccountNum == toAccountNum
                                select a.CheckingAccountID;
                    //gets first (only) thing from query list
                    Int32           accountID = query.First();
                    CheckingAccount toAccount = db.CheckingAccounts.Find(accountID);
                    toAccount.Transactions.Add(transaction);
                    toAccount.Balance = toAccount.Balance + transaction.Amount;
                }
                else if (toAccountType == "SAVING")
                {
                    var query = from a in db.SavingAccounts
                                where a.AccountNum == toAccountNum
                                select a.SavingAccountID;
                    //gets first (only) thing from query list
                    Int32         accountID = query.First();
                    SavingAccount toAccount = db.SavingAccounts.Find(accountID);
                    toAccount.Transactions.Add(transaction);
                    toAccount.Balance = toAccount.Balance + transaction.Amount;
                }
                else if (toAccountType == "IRA")
                {
                    var query = from a in db.IRAccounts
                                where a.AccountNum == toAccountNum
                                select a.IRAccountID;
                    //gets first (only) thing from query list
                    String    accountID = query.First();
                    IRAccount toAccount = db.IRAccounts.Find(accountID);

                    //if user is over 70, they cannot transfer into ira
                    if (UnderAgeLimt() == false)
                    {
                        return(Content("<script language'javascript' type = 'text/javascript'> alert('Error: Cannot contribute to IRA if you are older than 70.'); window.location='../Customer/Home';</script>"));
                    }

                    //if total contributions > 5000, they cannot deposit this amount
                    Decimal iraContributionTotal = TotalContributions(transaction.Amount);
                    if (iraContributionTotal > 5000)
                    {
                        Decimal maxTransferAmount = 5000 - (iraContributionTotal - transaction.Amount);
                        transaction.Amount        = maxTransferAmount;
                        ViewBag.MaxTransferAmount = maxTransferAmount.ToString();
                        ViewBag.Transaction       = transaction;
                        return(Content("<script language'javascript' type = 'text/javascript'> alert('Error: You have reached your contribution limit of $5000 for this year.'); window.location='../Customer/Home';</script>"));
                    }

                    toAccount.Transactions.Add(transaction);
                    toAccount.Balance = toAccount.Balance + transaction.Amount;
                }
                else if (toAccountType == "STOCKPORTFOLIO")
                {
                    var query = from a in db.StockPortfolios
                                where a.AccountNum == toAccountNum
                                select a.StockPortfolioID;
                    //gets first (only) thing from query list
                    String         accountID = query.First();
                    StockPortfolio toAccount = db.StockPortfolios.Find(accountID);
                    toAccount.Transactions.Add(transaction);
                    toAccount.Balance = toAccount.Balance + transaction.Amount;
                }


                if (fromAccountType == "CHECKING")
                {
                    var query = from a in db.CheckingAccounts
                                where a.AccountNum == fromAccountNum
                                select a.CheckingAccountID;
                    //gets first (only) thing from query list
                    Int32           accountID   = query.First();
                    CheckingAccount fromAccount = db.CheckingAccounts.Find(accountID);
                    //check if account is already overdrafted
                    if (fromAccount.Balance < 0)
                    {
                        return(Content("<script language'javascript' type = 'text/javascript'> alert('Error: You can't transfer money out of an overdrawn account.'); window.location='../Customer/Home';</script>"));
                    }
                    //check for overdraft strarts. if transaction will make balance <-50, return new view with error and autofilled max transaction
                    if (fromAccount.Balance - transaction.Amount < -50)
                    {
                        transaction.Amount = 50 + fromAccount.Balance;
                        ModelState.Clear();
                        ViewBag.listAccounts = GetListAccounts();
                        return(View("CreateAutoCorrect", transaction));
                    }
                    //if transaction makes balance between 0 and -50, add transaction, make new fee transaction of $30 on top of overdraft
                    else if (fromAccount.Balance - transaction.Amount < 0 && fromAccount.Balance - transaction.Amount >= -50)
                    {
                        fromAccount.Transactions.Add(transaction);

                        Transaction feeTransaction = new Transaction();
                        feeTransaction.TransType   = TransType.Fee;
                        feeTransaction.Amount      = 30;
                        feeTransaction.Date        = DateTime.Today;
                        feeTransaction.FromAccount = fromAccount.AccountNum;
                        feeTransaction.Description = "$30 fee from overdrafting";

                        fromAccount.Transactions.Add(feeTransaction);

                        fromAccount.Balance = fromAccount.Balance - transaction.Amount - feeTransaction.Amount;

                        //send email

                        string  userId    = User.Identity.GetUserId();
                        AppUser user      = db.Users.Find(userId);
                        string  userEmail = user.Email;

                        var query2 = from account2 in db.CheckingAccounts
                                     where account2.AccountNum == transaction.FromAccount
                                     select account2.CheckingAccountID;
                        Int32           fromAccountID = query.First();
                        CheckingAccount account       = db.CheckingAccounts.Find(fromAccountID);

                        Messaging.EmailMessaging.SendEmail(userEmail, "Overdraft on " + account.AccountName, account.AccountName + " is overdrawn and a $30.00 fee was added to your account. Your current balance on the account is -$" + (account.Balance * -1).ToString() + ".");
                    }
                    else
                    {
                        fromAccount.Transactions.Add(transaction);
                        fromAccount.Balance = fromAccount.Balance - transaction.Amount;
                    }
                }
                else if (fromAccountType == "SAVING")
                {
                    var query = from a in db.SavingAccounts
                                where a.AccountNum == fromAccountNum
                                select a.SavingAccountID;
                    //gets first (only) thing from query list
                    Int32         accountID   = query.First();
                    SavingAccount fromAccount = db.SavingAccounts.Find(accountID);
                    //check if account is already overdrafted
                    if (fromAccount.Balance < 0)
                    {
                        return(Content("<script language'javascript' type = 'text/javascript'> alert('Error: You can't transfer money out of an overdrawn account.'); window.location='../Customer/Home';</script>"));
                    }
                    //check for overdraft strarts. if transaction will make balance <-50, return new view with error and autofilled max transaction
                    if (fromAccount.Balance - transaction.Amount < -50)
                    {
                        transaction.Amount = 50 + fromAccount.Balance;
                        ModelState.Clear();
                        return(View("CreateAutoCorrect", transaction));
                    }
                    //if transaction makes balance between 0 and -50, add transaction, make new fee transaction of $30 on top of overdraft
                    else if (fromAccount.Balance - transaction.Amount < 0 && fromAccount.Balance - transaction.Amount >= -50)
                    {
                        fromAccount.Transactions.Add(transaction);

                        Transaction feeTransaction = new Transaction();
                        feeTransaction.TransType   = TransType.Fee;
                        feeTransaction.Amount      = 30;
                        feeTransaction.Date        = DateTime.Today;
                        feeTransaction.FromAccount = fromAccount.AccountNum;
                        feeTransaction.Description = "$30 fee from overdrafting";

                        fromAccount.Transactions.Add(feeTransaction);

                        fromAccount.Balance = fromAccount.Balance - transaction.Amount - feeTransaction.Amount;

                        //send email

                        string  userId    = User.Identity.GetUserId();
                        AppUser user      = db.Users.Find(userId);
                        string  userEmail = user.Email;

                        var query3 = from account in db.SavingAccounts
                                     where account.AccountNum == transaction.FromAccount
                                     select account.SavingAccountID;
                        //gets first (only) thing from query list
                        Int32         accountID3 = query.First();
                        SavingAccount a          = db.SavingAccounts.Find(accountID);

                        Messaging.EmailMessaging.SendEmail(userEmail, "Overdraft on " + a.AccountName, a.AccountName + " is overdrawn and a $30.00 fee was added to your account. Your current balance on the account is -$" + (a.Balance * -1).ToString() + ".");
                    }
                    else
                    {
                        fromAccount.Transactions.Add(transaction);
                        fromAccount.Balance = fromAccount.Balance - transaction.Amount;
                    }
                }

                else if (fromAccountType == "IRA")
                {
                    var query = from a in db.IRAccounts
                                where a.AccountNum == fromAccountNum
                                select a.IRAccountID;
                    //gets first (only) thing from query list
                    String    accountID   = query.First();
                    IRAccount fromAccount = db.IRAccounts.Find(accountID);

                    //checks if over 65, if so return error page
                    if (OverAgeLimt() == false)
                    {
                        if (transaction.Amount > 3000)
                        {
                            return(Content("<script language'javascript' type = 'text/javascript'> alert('Error: You cannot take out more $3000 from your IRA if you are under 65 years old.'); window.location='../Customer/Home';</script>"));
                        }
                        else
                        {
                            if (fromAccount.Balance < 0)
                            {
                                return(Content("<script language'javascript' type = 'text/javascript'> alert('Error: You can't transfer money out of an overdrawn account.'); window.location='../Customer/Home';</script>"));
                            }
                            if (fromAccount.Balance - transaction.Amount < -50)
                            {
                                transaction.Amount = 50 + fromAccount.Balance;
                                ModelState.Clear();
                                return(View("CreateAutoCorrect", transaction));
                            }
                            else if (fromAccount.Balance - transaction.Amount < 0 && fromAccount.Balance - transaction.Amount >= -50)
                            {
                                fromAccount.Transactions.Add(transaction);

                                Transaction ODfeeTransaction = new Transaction();
                                ODfeeTransaction.TransType   = TransType.Fee;
                                ODfeeTransaction.Amount      = 30;
                                ODfeeTransaction.Date        = DateTime.Today;
                                ODfeeTransaction.FromAccount = fromAccount.AccountNum;
                                ODfeeTransaction.Description = "$30 fee from overdrafting";
                                fromAccount.Transactions.Add(ODfeeTransaction);

                                //send email

                                string  userId    = User.Identity.GetUserId();
                                AppUser user      = db.Users.Find(userId);
                                string  userEmail = user.Email;

                                var query4 = from account4 in db.IRAccounts
                                             where account4.AccountNum == transaction.FromAccount
                                             select account4.IRAccountID;
                                //gets first (only) thing from query list
                                String    accountID4 = query4.First();
                                IRAccount a          = db.IRAccounts.Find(accountID);

                                IRAccount account = db.IRAccounts.Find(transaction.FromAccount);

                                Messaging.EmailMessaging.SendEmail(userEmail, "Overdraft on " + account.AccountName, account.AccountName + " is overdrawn and a $30.00 fee was added to your account. Your current balance on the account is -$" + (account.Balance * -1).ToString() + ".");

                                Transaction feeTransaction = new Transaction();
                                feeTransaction.TransType   = TransType.Fee;
                                feeTransaction.Date        = DateTime.Now;
                                feeTransaction.FromAccount = transaction.FromAccount;
                                feeTransaction.Amount      = 30;
                                feeTransaction.Description = "$30 Fee for transfering funds out of IRA when under 65 years old";
                                fromAccount.Transactions.Add(feeTransaction);

                                fromAccount.Balance = fromAccount.Balance - transaction.Amount - ODfeeTransaction.Amount - feeTransaction.Amount;
                            }
                        }
                    }
                    else
                    {
                        if (fromAccount.Balance < 0)
                        {
                            return(Content("<script language'javascript' type = 'text/javascript'> alert('Error: You can't transfer money out of an overdrawn account.'); window.location='../Customer/Home';</script>"));
                        }
                        if (fromAccount.Balance - transaction.Amount <= -50)
                        {
                            transaction.Amount = 50 + fromAccount.Balance;
                            ModelState.Clear();
                            return(View("CreateAutoCorrect", transaction));
                        }
                        else if (fromAccount.Balance - transaction.Amount < 0 && fromAccount.Balance - transaction.Amount >= -50)
                        {
                            fromAccount.Transactions.Add(transaction);

                            Transaction feeTransaction = new Transaction();
                            feeTransaction.TransType   = TransType.Fee;
                            feeTransaction.Amount      = 30;
                            feeTransaction.Date        = DateTime.Today;
                            feeTransaction.FromAccount = fromAccount.AccountNum;
                            feeTransaction.Description = "$30 fee from overdrafting";

                            fromAccount.Transactions.Add(feeTransaction);

                            fromAccount.Balance = fromAccount.Balance - transaction.Amount - feeTransaction.Amount;

                            //send email

                            string  userId    = User.Identity.GetUserId();
                            AppUser user      = db.Users.Find(userId);
                            string  userEmail = user.Email;

                            var query4 = from account4 in db.IRAccounts
                                         where account4.AccountNum == transaction.FromAccount
                                         select account4.IRAccountID;
                            //gets first (only) thing from query list
                            String    accountID4 = query4.First();
                            IRAccount account    = db.IRAccounts.Find(transaction.FromAccount);

                            Messaging.EmailMessaging.SendEmail(userEmail, "Overdraft on " + account.AccountName, account.AccountName + " is overdrawn and a $30.00 fee was added to your account. Your current balance on the account is -$" + (account.Balance * -1).ToString() + ".");
                        }
                        else
                        {
                            fromAccount.Transactions.Add(transaction);
                            fromAccount.Balance = fromAccount.Balance - transaction.Amount;
                        }
                    }
                }

                else if (fromAccountType == "STOCKPORTFOLIO")
                {
                    var query = from a in db.StockPortfolios
                                where a.AccountNum == fromAccountNum
                                select a.StockPortfolioID;
                    //gets first (only) thing from query list
                    String         accountID   = query.First();
                    StockPortfolio fromAccount = db.StockPortfolios.Find(accountID);
                    //check if account is already overdrafted
                    if (fromAccount.Balance < 0)
                    {
                        return(Content("<script language'javascript' type = 'text/javascript'> alert('Error: You can't transfer money out of an overdrawn account.'); window.location='../Customer/Home';</script>"));
                    }
                    //check for overdraft strarts. if transaction will make balance <-50, return new view with error and autofilled max transaction
                    if (fromAccount.Balance - transaction.Amount < -50)
                    {
                        transaction.Amount = 50 + fromAccount.Balance;
                        ModelState.Clear();
                        return(View("CreateAutoCorrect", transaction));
                    }
                    //if transaction makes balance between 0 and -50, add transaction, make new fee transaction of $30 on top of overdraft
                    else if (fromAccount.Balance - transaction.Amount < 0 && fromAccount.Balance - transaction.Amount >= -50)
                    {
                        fromAccount.Transactions.Add(transaction);

                        Transaction feeTransaction = new Transaction();
                        feeTransaction.TransType   = TransType.Fee;
                        feeTransaction.Amount      = 30;
                        feeTransaction.Date        = DateTime.Today;
                        feeTransaction.FromAccount = fromAccount.AccountNum;
                        feeTransaction.Description = "$30 fee from overdrafting";

                        fromAccount.Transactions.Add(feeTransaction);

                        fromAccount.Balance = fromAccount.Balance - transaction.Amount - feeTransaction.Amount;

                        //send email

                        string  userId    = User.Identity.GetUserId();
                        AppUser user      = db.Users.Find(userId);
                        string  userEmail = user.Email;

                        var query4 = from account4 in db.StockPortfolios
                                     where account4.AccountNum == transaction.FromAccount
                                     select account4.StockPortfolioID;
                        //gets first (only) thing from query list
                        String         accountID4 = query4.First();
                        StockPortfolio account    = db.StockPortfolios.Find(accountID);

                        Messaging.EmailMessaging.SendEmail(userEmail, "Overdraft on " + account.AccountName, account.AccountName + " is overdrawn and a $30.00 fee was added to your account. Your current balance on the account is -$" + (account.Balance * -1).ToString() + ".");
                    }
                    else
                    {
                        fromAccount.Transactions.Add(transaction);
                        fromAccount.Balance = fromAccount.Balance - transaction.Amount;
                    }
                }

                db.SaveChanges();

                return(Content("<script language'javascript' type = 'text/javascript'> alert('Confirmation: Transfer successfull!'); window.location='../Customer/Home';</script>"));
            }

            List <AccountsViewModel> allAccounts = GetAccounts();
            SelectList selectAccounts            = new SelectList(allAccounts.OrderBy(q => q.AccountName), "AccountNum", "AccountName");

            ViewBag.allAccounts  = selectAccounts;
            ViewBag.listAccounts = GetListAccounts();
            return(View(transaction));
        }