예제 #1
0
        public ActionResult AdminHome()
        {
            //This retrieves the userID that is associated with the username in the tables
            int SessionUserID = WebSecurity.GetUserId(User.Identity.Name);

            NWBAEntities db = new NWBAEntities();
            var query = (from x in db.Customers
                         where x.CustomerID.Equals(SessionUserID)
                         select x).Single();

            var newModel = new UserHome_ViewModel()
            {
                CustomerName = query.CustomerName
            };

            return View(newModel);
        }
예제 #2
0
 public ActionResult ChangeUserDetails()
 {
     NWBAEntities db = new NWBAEntities();
     var CustomerLinqList = (from x in db.Customers
                             select new EditProfile_ViewModel()
                             {
                                 CustomerID = x.CustomerID,
                                 CustomerName = x.CustomerName,
                                 TFN = x.TFN,
                                 Address = x.Address,
                                 City = x.City,
                                 State = x.State,
                                 PostCode = x.PostCode,
                                 Phone = x.Phone,
                             }).ToList();
     return View(CustomerLinqList);
 }
예제 #3
0
        /*PayBillScheduleGet
         *This creates the viewmodel to displays the the grid of schdueled jobs for the user
         */
        public ATMBillSchedule_ViewModel billSchedule(int sessionID)
        {
            NWBAEntities db = new NWBAEntities();

            var customerQuery = Repo.GetCustomerSingle(sessionID);
            var AccountListQuery = Repo.GetCustomerAccountQueryable(sessionID);

            IEnumerable<SelectListItem> account = AccountListQuery.OrderBy(a => a.AccountNumber).ToList().Select(a => new SelectListItem
            {
                Value = Convert.ToString(a.AccountNumber),
                Text = (a.AccountType.Equals("S")) ? "Savings - " + a.AccountNumber.ToString() : "Checkings - " + a.AccountNumber.ToString()
            });

            var newModel = new ATMBillSchedule_ViewModel
            {
                CustomerName = customerQuery.CustomerName,
                accountList = account,
                scheduleBillList = new List<BillingList>()
            };
            return newModel;
        }
예제 #4
0
        /*
        This will manually create a job to add to the job service
         * Used when the user creates a billpay job using the web site
         * */
        public void manualCreateBPayJob(int accountNumber, int payeeID, decimal amount, string period, DateTime schedDate)
        {
            //create a database record for the newly created job then  retrive the database geneted billpay id and pass
            //it to the createScheduledJobService so it can add the job to the job service
            Debug.WriteLine("Creating and Adding a Bew Bill Pay Record to the Billpay table");
            using (NWBAEntities db = new NWBAEntities())
            {
                BillPay newBillPayRecord = new BillPay();
                newBillPayRecord.AccountNumber = accountNumber;
                newBillPayRecord.PayeeID = payeeID;
                newBillPayRecord.Amount = amount;
                newBillPayRecord.Period = period;
                newBillPayRecord.ScheduleDate = schedDate;
                newBillPayRecord.ModifyDate = DateTime.Now;

                db.BillPays.Add(newBillPayRecord);
                db.SaveChanges();
                int billPayID = newBillPayRecord.BillPayID; //EF will update the entity object with the database generated identity

                //Now we can create a job and add it to the schduler since we have a BillpayID to identify the job
                createScheduledJobService(billPayID, accountNumber, payeeID, amount, period[0], schedDate);

            }
        }
예제 #5
0
        //WithdrawalPost
        public ATMWithdraw_ViewModel WithdrawalPost(int sessionUserID, ATMWithdraw_ViewModel models)
        {
            NWBAEntities db = new NWBAEntities();

            int accountNumber = models.FromAccountNumber;
            var accountQuery = Repo.GetAccount(accountNumber);

            if (accountNumber != 0)
            {
                decimal amount = models.Amount;
                decimal newBalance;
                decimal balanceThreshold;
                int transactionCountCheck = calculateTransactionCount(accountNumber);

                if (transactionCountCheck >= MAX_FREE_TRANSACTIONS)
                {
                    newBalance = accountQuery.Balance - amount - (decimal)0.20;
                }
                else
                {
                    newBalance = accountQuery.Balance - amount;
                }

                if (accountQuery.AccountType.Equals("S"))
                {
                    balanceThreshold = SAVINGS_MINIMAL_BALANCE;
                }
                else
                {
                    balanceThreshold = CHECKING_MINIMAL_BALANCE;
                }

                if (newBalance >= balanceThreshold)
                {
                    DateTime modifiedDate = System.DateTime.Now;

                    Account updateAccount = db.Accounts.First(i => i.AccountNumber.Equals(accountNumber));
                    updateAccount.Balance = newBalance;
                    updateAccount.ModifyDate = modifiedDate;

                    Repo.UpdateExistingAccount(updateAccount);

                    Transaction newTransaction = new Transaction
                    {
                        TransactionType = "W",
                        AccountNumber = accountNumber,
                        Amount = amount,
                        Comment = models.Comment,
                        ModifyDate = modifiedDate
                    };
                    Repo.AddTransaction(newTransaction);

                    if (transactionCountCheck >= MAX_FREE_TRANSACTIONS)
                    {
                        Transaction serviceTransaction = new Transaction
                        {
                            TransactionType = "S",
                            AccountNumber = accountNumber,
                            Amount = (decimal)0.20,
                            Comment = "Service Charge",
                            ModifyDate = modifiedDate
                        };
                        Repo.AddTransaction(serviceTransaction);
                    }
                    else
                    {
                        Transaction serviceTransaction = new Transaction
                        {
                            TransactionType = "S",
                            AccountNumber = accountNumber,
                            Amount = (decimal)0.00,
                            Comment = "Free Service Charge",
                            ModifyDate = modifiedDate
                        };
                        Repo.AddTransaction(serviceTransaction);
                    }

                    models.Message = "Withdrawal SUCCESSFUL.";
                }
                else
                {
                    models.Message = "Withdrawal UNSUCCESSFUL.";
                }
            }
            var accountListQuery = Repo.GetCustomerAccountQueryable(sessionUserID);

            IEnumerable<SelectListItem> accounts = accountListQuery.OrderBy(a => a.AccountNumber).ToList().Select(a => new SelectListItem
            {
                Value = Convert.ToString(a.AccountNumber),
                Text = (a.AccountType.Equals("S")) ? "Savings - " + a.AccountNumber.ToString() + " - $" + a.Balance
                                                        : "Checkings - " + a.AccountNumber.ToString() + " - $" + a.Balance
            });

            Customer customerQuery = Repo.GetCustomerSingle(sessionUserID);

            decimal formatAccountBalance = Convert.ToDecimal(string.Format("{0:0.00}", accountQuery.Balance));

            models.AccountList = accounts;
            models.CustomerName = customerQuery.CustomerName;
            models.AccountBalanceMessage = "Account Balance: " + formatAccountBalance;

            return models;
        }
예제 #6
0
        //TransferPost
        public ATMTransfer_ViewModel TransferPost(int sessionUserID, ATMTransfer_ViewModel models)
        {
            decimal newBalanceFrom;
            decimal balanceThreshold;
            NWBAEntities db = new NWBAEntities();
            int fromAccountNumber = models.FromAccountNumber;

            if (fromAccountNumber != 0)
            {
                int toAccountNumber = models.ToAccountNumber;

                var fromAccountQuery = Repo.GetAccount(fromAccountNumber);

                int transactionCountCheck = calculateTransactionCount(fromAccountNumber);

                decimal amount = models.Amount;

                if (transactionCountCheck >= MAX_FREE_TRANSACTIONS)
                {
                    newBalanceFrom = fromAccountQuery.Balance - amount - (decimal)0.20;
                }
                else
                {
                    newBalanceFrom = fromAccountQuery.Balance - amount;
                }

                if (fromAccountQuery.AccountType.Equals("S"))
                {
                    balanceThreshold = SAVINGS_MINIMAL_BALANCE;
                }
                else
                {
                    balanceThreshold = CHECKING_MINIMAL_BALANCE;
                }

                if (newBalanceFrom >= balanceThreshold)
                {
                    DateTime modifiedDateFrom = System.DateTime.Now;

                    Account updateAccountFrom = db.Accounts.First(i => i.AccountNumber.Equals(fromAccountNumber));
                    updateAccountFrom.Balance = newBalanceFrom;
                    updateAccountFrom.ModifyDate = modifiedDateFrom;

                    Repo.UpdateExistingAccount(updateAccountFrom);

                    Transaction newTransactionWithdraw = new Transaction
                    {
                        TransactionType = "T",
                        AccountNumber = fromAccountNumber,
                        DestAccount = toAccountNumber,
                        Amount = amount,
                        Comment = models.Comment,
                        ModifyDate = modifiedDateFrom
                    };
                    Repo.AddTransaction(newTransactionWithdraw);

                    if (transactionCountCheck >= MAX_FREE_TRANSACTIONS)
                    {
                        Transaction serviceTransaction = new Transaction
                        {
                            TransactionType = "S",
                            AccountNumber = fromAccountNumber,
                            Amount = (decimal)0.20,
                            Comment = "Service Charge",
                            ModifyDate = modifiedDateFrom
                        };
                        Repo.AddTransaction(serviceTransaction);
                    }
                    else
                    {
                        Transaction serviceTransaction = new Transaction
                        {
                            TransactionType = "S",
                            AccountNumber = fromAccountNumber,
                            Amount = (decimal)0.00,
                            Comment = "Free Service Charge",
                            ModifyDate = modifiedDateFrom
                        };
                        Repo.AddTransaction(serviceTransaction);
                    }

                    if (toAccountNumber != 0)
                    {
                        var toAccountQuery = Repo.GetAccount(toAccountNumber);

                        decimal newBalanceTo = toAccountQuery.Balance + amount;
                        DateTime modifiedDateTo = System.DateTime.Now;

                        Account updateAccountTo = db.Accounts.First(i => i.AccountNumber.Equals(toAccountNumber));
                        updateAccountTo.Balance = newBalanceTo;
                        updateAccountTo.ModifyDate = modifiedDateTo;
                        Repo.UpdateExistingAccount(updateAccountTo);

                        Transaction newTransactionDeposit = new Transaction
                        {
                            TransactionType = "D",
                            AccountNumber = toAccountNumber,
                            DestAccount = toAccountNumber,
                            Amount = amount,
                            Comment = models.Comment,
                            ModifyDate = modifiedDateTo
                        };
                        Repo.AddTransaction(newTransactionDeposit);
                    }
                    models.Message = "Transfer SUCCESSFUL.";
                }
                else
                {
                    models.Message = "Transfer UNSUCCESSFUL.";
                }

                var accountListQuery = (from x in db.Accounts
                                        where x.CustomerID.Equals(sessionUserID)
                                        select x);

                var allAccountQuery = (from x in db.Accounts
                                       where x.CustomerID.Equals(sessionUserID)
                                       select x);

                IEnumerable<SelectListItem> allAccounts = allAccountQuery.OrderBy(a => a.AccountNumber).ToList().Select(a => new SelectListItem
                {
                    Value = Convert.ToString(a.AccountNumber),
                    Text = (a.AccountType.Equals("S")) ? "Savings - " + a.AccountNumber.ToString() : "Checkings - " + a.AccountNumber.ToString()
                });

                IEnumerable<SelectListItem> accounts = accountListQuery.OrderBy(a => a.AccountNumber).ToList().Select(a => new SelectListItem
                {
                    Value = Convert.ToString(a.AccountNumber),
                    Text = (a.AccountType.Equals("S")) ? "Savings - " + a.AccountNumber.ToString() + " - $" + a.Balance
                                                       : "Checkings - " + a.AccountNumber.ToString() + " - $" + a.Balance
                });

                var customerQuery = Repo.GetCustomerSingle(sessionUserID);

                decimal formatAccountBalance = Convert.ToDecimal(string.Format("{0:0.00}", fromAccountQuery.Balance));

                models.AccountList = accounts;
                models.AllAccountList = allAccounts;
                models.CustomerName = customerQuery.CustomerName;
                models.AccountBalanceMessage = "Account Balance: " + formatAccountBalance;
            }
            return models;
        }
예제 #7
0
        //########################## DONT TOUCH BELOW UNTIL REPO FIXED
        //TransferGet
        //Transfer Page display
        public ATMTransfer_ViewModel Transfer(int sessionUserID)
        {
            NWBAEntities db = new NWBAEntities();

            var customerQuery = Repo.GetCustomerSingle(sessionUserID);
            var accountQuery = Repo.GetCustomerAccountQueryable(sessionUserID);

            if (HttpContext.Current.Session["fromAccountNumber"] != null)
            {
                int fromAccountNumber = (int)HttpContext.Current.Session["fromAccountNumber"];

                var allAccountQuery = (from x in db.Accounts
                                       where x.AccountNumber != fromAccountNumber
                                       select x);

                IEnumerable<SelectListItem> accounts = accountQuery.OrderBy(a => a.AccountNumber).ToList().Select(a => new SelectListItem
                {
                    Value = Convert.ToString(a.AccountNumber),
                    Text = (a.AccountType.Equals("S")) ? "Savings - " + a.AccountNumber.ToString() + " - $" + a.Balance
                                                           : "Checkings - " + a.AccountNumber.ToString() + " - $" + a.Balance
                });

                IEnumerable<SelectListItem> allAccounts = allAccountQuery.OrderBy(a => a.AccountNumber).ToList().Select(a => new SelectListItem
                {
                    Value = Convert.ToString(a.AccountNumber),
                    Text = (a.AccountType.Equals("S")) ? "Savings - " + a.AccountNumber.ToString() : "Checkings - " + a.AccountNumber.ToString()
                });

                var newModel = new ATMTransfer_ViewModel()
                {
                    CustomerName = customerQuery.CustomerName,
                    AccountList = accounts,
                    AllAccountList = allAccounts
                };
                return newModel;
            }
            else
            {
                //get all accounts EXCEPT the currently logged in user
                var allAccountQuery = Repo.GetAllAccountsExceptUser(sessionUserID);

                IEnumerable<SelectListItem> accounts = accountQuery.OrderBy(a => a.AccountNumber).ToList().Select(a => new SelectListItem
                {
                    Value = Convert.ToString(a.AccountNumber),
                    Text = (a.AccountType.Equals("S")) ? "Savings - " + a.AccountNumber.ToString() + " - $" + a.Balance
                                                           : "Checkings - " + a.AccountNumber.ToString() + " - $" + a.Balance
                });

                IEnumerable<SelectListItem> allAccounts = allAccountQuery.OrderBy(a => a.AccountNumber).ToList().Select(a => new SelectListItem
                {
                    Value = Convert.ToString(a.AccountNumber),
                    Text = (a.AccountType.Equals("S")) ? "Savings - " + a.AccountNumber.ToString() : "Checkings - " + a.AccountNumber.ToString()
                });

                var newModel = new ATMTransfer_ViewModel()
                {
                    CustomerName = customerQuery.CustomerName,
                    AccountList = accounts,
                    AllAccountList = allAccounts
                };
                return newModel;
            }
        }
예제 #8
0
        /*PayBillSchedulePost
         *User submits the view to view the pending billpay jobs
         *This post also retrieves the current jobs for the particular account and creates a list for the view to display
         */
        public ATMBillSchedule_ViewModel billSchedulePost(int sessionID, ATMBillSchedule_ViewModel models)
        {
            NWBAEntities db = new NWBAEntities();
            int accountID = models.AccountNumber;

            if (accountID != 0)
            {
                var accountQuery = Repo.GetAccount(accountID);
                var customerQuery = Repo.GetCustomerAccountQueryable(sessionID);
                var singleCustomerQuery = Repo.GetCustomerSingle(sessionID);

                IEnumerable<SelectListItem> accounts = customerQuery.OrderBy(c => c.AccountNumber).ToList().
                         Select(c => new SelectListItem
                         {
                             Value = Convert.ToString(c.AccountNumber),
                             Text = (c.AccountType.Equals("S")) ? "Saving " + c.AccountNumber.ToString()
                             : "Checkings " + " " + c.AccountNumber.ToString()
                         });

                //This fetches a list of current billpay jobs scheduled #########

                var currentJobsList = Repo.GetCurrentBillPayJobs();

                //Get all Billpay records in the system that are currently being schedueld and for the particular account
                var billList = (from a in db.BillPays
                                where a.AccountNumber.Equals(accountID) && currentJobsList.Contains(a.BillPayID)
                                select a);

                var payeeList = Repo.GetAllPayeeQueryable();

                //If the account has at least 1 schecduled billpay job
                //enter this if, Else display empty record string
                if (billList.Count() > 0)
                {
                    //select [WDT].[dbo].[Payee].PayeeName, [WDT].[dbo].[BillPay].PayeeID,
                    //       [WDT].[dbo].[BillPay].Amount, [WDT].[dbo].[BillPay].ScheduleDate, [WDT].[dbo].[BillPay].Period
                    //from [WDT].[dbo].[Payee]
                    //join [WDT].[dbo].[BillPay]
                    //on [WDT].[dbo].[Payee].PayeeID=[WDT].[dbo].[BillPay].PayeeID

                    //Creates a list of billing list objects which is needed by the grid to display the current scheduled jobs for the account
                    List<BillingList> BillPayGridList = new List<BillingList>();

                    // Contains an annomous object with properties from billpay and payee
                    //A list of current billpay jobs with information from payee table
                    var CustomScheduledList = (from x in db.BillPays
                                               join y in db.Payees on x.PayeeID equals y.PayeeID
                                               where x.AccountNumber.Equals(accountID) && currentJobsList.Contains(x.BillPayID)
                                               select new
                                               {
                                                   x.BillPayID,
                                                   y.PayeeName,
                                                   x.Amount,
                                                   x.ScheduleDate,
                                                   x.Period
                                               });

                    foreach (var z in CustomScheduledList)
                    {
                        string scheduleDateFormat = z.ScheduleDate.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture);

                        BillingList bl = new BillingList();
                        bl.BillPayID = z.BillPayID;
                        bl.PayeeName = z.PayeeName;
                        bl.Amount = (double)z.Amount;
                        bl.ScheduleDate = scheduleDateFormat;
                        bl.Period = z.Period;

                        BillPayGridList.Add(bl);
                    }

                    models.CustomerName = singleCustomerQuery.CustomerName;
                    models.AccountNumber = accountID;
                    models.accountList = accounts;
                    models.scheduleBillList = BillPayGridList;
                }
                else
                {
                    //This part basically creates a viewmodel that tells the user
                    //they dont have any schduled bill pay jobs
                    List<BillingList> bList = new List<BillingList>();
                    models.CustomerName = singleCustomerQuery.CustomerName;
                    models.AccountNumber = accountID;
                    models.accountList = accounts;
                    models.scheduleBillList = bList;
                    models.Message = "Empty Record";
                }
            }
            else
            {
                billSchedule(sessionID);
            }
            return models;
        }
예제 #9
0
        //StatementPost
        public Statement_ViewModel postStatement(int sessionID, Statement_ViewModel models)
        {
            using (NWBAEntities db = new NWBAEntities())
            {
                int accountID = models.AccountNumber;

                if (accountID != 0)
                {
                    var accountQuery = Repo.GetAccount(accountID);
                    var customerAccountsQuery = Repo.GetCustomerAccountQueryable(sessionID);

                    IEnumerable<SelectListItem> accounts = customerAccountsQuery.OrderBy(c => c.AccountNumber).ToList().
                         Select(c => new SelectListItem
                         {
                             Value = Convert.ToString(c.AccountNumber),
                             Text = (c.AccountType.Equals("S")) ? "Saving " + c.AccountNumber.ToString()
                             : "Checkings " + " " + c.AccountNumber.ToString()
                         });

                    decimal balance = 0;
                    decimal minSbalance = 0.20M;
                    decimal minCbalance = 200.20M;
                    decimal transactionFee = 0.20M;
                    decimal balanceThreshold;
                    Boolean check = false;

                    if (accountQuery.AccountType.Equals("S"))
                    {
                        if (accountQuery.Balance >= minSbalance)
                        {
                            balance = accountQuery.Balance - transactionFee;
                            check = true;
                        }
                        else
                        {
                            balance = accountQuery.Balance;
                        }
                    }
                    else if (accountQuery.AccountType.Equals("C"))
                    {
                        if (accountQuery.Balance >= minCbalance)
                        {
                            balance = accountQuery.Balance - transactionFee;
                            check = true;
                        }
                        else
                        {
                            balance = accountQuery.Balance;
                        }
                    }

                    if (accountQuery.AccountType.Equals("S"))
                    {
                        balanceThreshold = SAVINGS_MINIMAL_BALANCE;
                    }
                    else
                    {
                        balanceThreshold = CHECKING_MINIMAL_BALANCE;
                    }

                    if (balance >= balanceThreshold && check)
                    {
                        DateTime date = System.DateTime.Now;
                        Account updateAccount = db.Accounts.First(u => u.AccountNumber.Equals(accountID));
                        updateAccount.Balance = Convert.ToDecimal(string.Format("{0:0.00}", balance));
                        updateAccount.ModifyDate = date;
                        Repo.UpdateExistingAccount(updateAccount);

                        Transaction serviceTransaction = new Transaction
                        {
                            TransactionType = "S",
                            AccountNumber = accountID,
                            Amount = Convert.ToDecimal(string.Format("{0:0.00}", transactionFee)),
                            Comment = "View Statement Charge",
                            ModifyDate = date
                        };
                        Repo.AddTransaction(serviceTransaction);

                        models.retrieveMessage = "Transaction History Retrieved SUCCESSFULLY";

                        var sList = (from a in db.Transactions
                                     where a.AccountNumber.Equals(accountID)
                                     select a);

                        models.AccountNumber = accountID;
                        models.tranList = sList.ToList();
                        models.accountList = accounts;
                        models.Balance = Convert.ToDecimal(string.Format("{0:0.00}", balance));
                    }
                    else
                    {
                        models.retrieveMessage = "Transaction History Was Unable To Retrieve Due To INSUFFICIENT Amount";
                        var aList = (from a in db.Transactions
                                     where a.AccountNumber.Equals(0)
                                     select a);
                        models.AccountNumber = accountID;
                        models.accountList = accounts;
                        models.Balance = Convert.ToDecimal(string.Format("{0:0.00}", balance));
                        models.tranList = aList.ToList();
                    }
                }
                else
                {
                    return getStatement(sessionID);
                }
                return models;
            }
        }
예제 #10
0
        //StatementGet
        public Statement_ViewModel getStatement(int sessionID)
        {
            NWBAEntities db = new NWBAEntities();

            var AccountListQuery = Repo.GetCustomerAccountQueryable(sessionID);

            IEnumerable<SelectListItem> accounts = AccountListQuery.OrderBy(a => a.AccountNumber).ToList().Select(a => new SelectListItem
            {
                Value = Convert.ToString(a.AccountNumber),
                Text = (a.AccountType.Equals("S")) ? "Savings - " + a.AccountNumber.ToString() : "Checkings - " + a.AccountNumber.ToString()
            });

            if (HttpContext.Current.Session["accountNumber"] != null)
            {
                int accountNumber = (int)HttpContext.Current.Session["accountNumber"];
                var transList = (from a in db.Transactions
                                 where a.AccountNumber.Equals(accountNumber)
                                 select a);

                var accountQuery = (from x in db.Accounts
                                    where x.CustomerID.Equals(sessionID) && x.AccountNumber.Equals(accountNumber)
                                    select x).Single();

                var model = new Statement_ViewModel()
                {
                    accountList = accounts,
                    tranList = transList.ToList(),
                    Balance = Convert.ToDecimal(string.Format("{0:0.00}", accountQuery.Balance))
                };
                return model;
            }
            else
            {
                var transList = (from a in db.Transactions
                                 where a.AccountNumber.Equals(0)
                                 select a);

                var model = new Statement_ViewModel()
                {
                    accountList = accounts,
                    tranList = transList.ToList(),
                };
                return model;
            }
        }
예제 #11
0
        //DepositPost
        public ATMDeposit_ViewModel DepositPost(int sessionID, ATMDeposit_ViewModel models)
        {
            NWBAEntities db = new NWBAEntities();

            int accountNumber = models.ToAccountNumber;

            if (accountNumber != 0)
            {
                var accountQuery = Repo.GetAccount(accountNumber);
                decimal amount = models.Amount;

                decimal newBalance = accountQuery.Balance + amount;
                DateTime modifiedDate = System.DateTime.Now;

                Account updateAccount = Repo.GetAccount(accountNumber);
                updateAccount.Balance = newBalance;
                updateAccount.ModifyDate = modifiedDate;

                Repo.UpdateExistingAccount(updateAccount);

                Transaction newTransaction = new Transaction
                {
                    TransactionType = "D",
                    AccountNumber = accountNumber,
                    DestAccount = accountNumber,
                    Amount = amount,
                    Comment = models.Comment,
                    ModifyDate = modifiedDate
                };
                Repo.AddTransaction(newTransaction);

                models.Message = "Deposit SUCCESSFUL.";

                var accountListQuery = (from x in db.Accounts
                                        where x.CustomerID.Equals(sessionID)
                                        select x);

                IEnumerable<SelectListItem> accounts = accountListQuery.OrderBy(a => a.AccountNumber).ToList().Select(a => new SelectListItem
                {
                    Value = Convert.ToString(a.AccountNumber),
                    Text = (a.AccountType.Equals("S")) ? "Savings - " + a.AccountNumber.ToString() + " - $" + a.Balance
                                                       : "Checkings - " + a.AccountNumber.ToString() + " - $" + a.Balance
                });

                var customerQuery = Repo.GetCustomerSingle(sessionID);

                decimal formatAccountBalance = Convert.ToDecimal(string.Format("{0:0.00}", accountQuery.Balance));

                models.AccountList = accounts;
                models.CustomerName = customerQuery.CustomerName;
                models.AccountBalanceMessage = "Account Balance: " + formatAccountBalance;
            }
            return models;
        }
예제 #12
0
 //######################################### HELPER METHODS ##########################################
 //Helper Methood, calculates the number of transactions they currently have in the system.
 //Needed to determine whether to apply a fee
 private int calculateTransactionCount(int accountNumber)
 {
     NWBAEntities db = new NWBAEntities();
     var transactionQuery = (from x in db.Transactions
                             where x.AccountNumber.Equals(accountNumber) &&
                             (x.TransactionType.Equals("W") || x.TransactionType.Equals("T") ||
                             x.TransactionType.Equals("B"))
                             select x);
     return transactionQuery.ToArray().Length;
 }
예제 #13
0
        public ActionResult GridUpdate(int Customerid)
        {
            //Above, id passed in represents the unique primary key for each row, more properties can be passed in if
            // needed eg (int id,string CustomerName)

            //Creating another viewmodel so it can be used to data validation
            //need to assign it the customer id passed from the view so the object can be passed to the repositry method to add to db
            //TO BE IMPLEMENTED LATER, AT the moment, doing nothing major
            var customerObject = new EditProfile_ViewModel
            {
                CustomerID = Convert.ToInt32(Customerid)
            };

            //Perform model binding from the view to the newly created viewmodel then validate if passes data annotations
            //Reference: http://msdn.microsoft.com/en-us/library/system.web.mvc.controller.tryupdatemodel%28v=vs.108%29.aspx
            if (TryUpdateModel(customerObject))
            {
                NWBAEntities db = new NWBAEntities();
                Debug.WriteLine("Update Validation Passed");
                Customer customerRecord = (from x in db.Customers
                                           where x.CustomerID.Equals(Customerid)
                                           select x).SingleOrDefault();

                customerRecord.CustomerName = customerObject.CustomerName;
                customerRecord.TFN = customerObject.TFN;
                customerRecord.Address = customerObject.Address;
                customerRecord.City = customerObject.City;
                customerRecord.State = customerObject.State;
                customerRecord.PostCode = customerObject.PostCode;
                customerRecord.Phone = customerObject.Phone;

                db.SaveChanges();
                Debug.WriteLine("Updated Record in DB");
                return RedirectToAction("ChangeUserDetails", this.GridRouteValues());
            }

            Debug.WriteLine("Update Validation Failed");
            return RedirectToAction("ChangeUserDetails", this.GridRouteValues());
        }
예제 #14
0
        public ActionResult ViewTransactions(string id)
        {
            var models = new CustomerListTransactions_ViewModel();
            NWBAEntities db = new NWBAEntities();
            var AccountList = (from x in db.Accounts
                               select x).ToList();
            models.ListAccount = AccountList;

            //Intially, when loaded,no user has been selected
            if (string.IsNullOrEmpty(id))
            {
                models.selectedAccount = "";
            }
            models.selectedAccount = id;
            //Convert require since LINQ does not support casting inline
            int idInt = Convert.ToInt32(id);
            // Returns a list of transations that matches the account number
            var TransactionList = (from x in db.Transactions
                                   where x.AccountNumber == idInt
                                   select x).ToList();
            models.ListTransaction = TransactionList;
            return View(models);
        }
예제 #15
0
        public ActionResult ViewAccountDetails()
        {
            var models = new AccountList_ViewModel();

            /*LINQ statement to select * from customer and account tables.
             * Each record will create a CustomerAccount object with information from both tables
             * The query will return a IEnurable collection of CustomerAccount_View objects/types
             * The CustomerAccount_View is a POCO with properties from 2 db tables
             */
            NWBAEntities db = new NWBAEntities();
            var query = (from x in db.Accounts
                         join y in db.Customers on x.CustomerID equals y.CustomerID
                         select new CustomerAccount_View()
                         {
                             MyAccountNumber = x.AccountNumber,
                             MyAccountType = x.AccountType,
                             MyCustomerID = y.CustomerID,
                             MyCustomerName = y.CustomerName,
                             MyModifyDate = x.ModifyDate
                         });

            //Adding each account record to the viewmodel list which will passed to the view
            foreach (var i in query)
            {
                models.ListAccounts.Add(i);
            }
            return View(models);
        }
예제 #16
0
        public ActionResult StopScheduledPayments()
        {
            Debug.WriteLine("Inside Stop Schduled payment View Model in Admin Controller");

            //This model will contains 2 lists which are needed to populate the 2 grids for this view
            var models = new BillPayList_ViewModel();

            //Request a list of current active scheduled jobs(BillPayID's) from the scheduler
            Billpay billPayObject = new Billpay();
            List<int> currentActiveBillPayJobs = billPayObject.GetAllActiveJobs();

            //LINQ statement to return billPayee_view objects inside an iquerable
            //This linq will return only billpays for current jobs that have been scheduled because of the passed in currentBillPayJobs
            //Each record will create a CustomerAccount object with information from both tables
            //The query will return a IEnurable collection of CustomerAccount_View objects/types
            //The CustomerAccount_View is a POCO with properties from 2 db tables
            using (NWBAEntities db = new NWBAEntities())
            {
                var query = (from x in db.BillPays
                             join y in db.Payees on x.PayeeID equals y.PayeeID
                             where currentActiveBillPayJobs.Contains(x.BillPayID)
                             select new BillPayPayee_View()
                             {
                                 MyBillPayID = x.BillPayID,
                                 MyAccountNumber = x.AccountNumber,
                                 MyPayeeID = x.PayeeID,
                                 MyAmount = x.Amount,
                                 MyScheduleDate = x.ScheduleDate,
                                 MyPeriod = x.Period,
                                 MyModifyDate = x.ModifyDate,
                                 MyPayeeName = y.PayeeName
                             });

                //Adding each account record to the viewmodel list which will passed to the view
                //Cheap and nasty way instead of using .toList
                foreach (var i in query)
                {
                    models.ActiveBPayJobsGrid.Add(i);
                }

                //Request a list of current Paused scheduled jobs(BillPayID's) from the scheduler
                List<int> currentPausedBillPayJobs = billPayObject.GetAllPausedJobs();

                var query2 = (from x in db.BillPays
                             join y in db.Payees on x.PayeeID equals y.PayeeID
                              where currentPausedBillPayJobs.Contains(x.BillPayID)
                             select new BillPayPayee_View()
                             {
                                 MyBillPayID = x.BillPayID,
                                 MyAccountNumber = x.AccountNumber,
                                 MyPayeeID = x.PayeeID,
                                 MyAmount = x.Amount,
                                 MyScheduleDate = x.ScheduleDate,
                                 MyPeriod = x.Period,
                                 MyModifyDate = x.ModifyDate,
                                 MyPayeeName = y.PayeeName
                             });

                //Adding each account record to the viewmodel list which will passed to the view
                //Cheap and nasty way instead of using .toList
                foreach (var i in query2)
                {
                    models.PausedBPayJobsGrid.Add(i);
                }
                return View(models);
            }
        }