/*PayBillsPost *Triggered when the user submits the form for processing once they have filled in the details * about the scheduled billpay job they want to schedule. */ public ATMPayBills_ViewModel PayBillsPost(int sessionUserID, ATMPayBills_ViewModel models) { //Now adding the job to the schuduler to be fired off in 1minute Billpay BPayReference = new Billpay(); BPayReference.manualCreateBPayJob(models.FromAccountNumber, models.Payee, models.Amount, models.Period, models.ScheduledDate); Customer customerQuery = Repo.GetCustomerSingle(sessionUserID); var accountQuery = Repo.GetCustomerAccountQueryable(sessionUserID); var allPayeeQuery = Repo.GetAllPayeeQueryable(); 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> allPayee = allPayeeQuery.OrderBy(p => p.PayeeID).ToList().Select(p => new SelectListItem { Value = Convert.ToString(p.PayeeID), Text = (p.PayeeID + " - " + p.PayeeName) }); models.CustomerName = customerQuery.CustomerName; models.AccountList = accounts; models.AllPayeeList = allPayee; models.Message = "Bill Pay Schedule Recorded/Scheduled SUCCESSFULLY"; return models; }
public ActionResult PayBills(ATMPayBills_ViewModel models) { int sessionUserID = WebSecurity.GetUserId(User.Identity.Name); Bank bank = new Bank(); ATMPayBills_ViewModel payBillView; if (ModelState.IsValid) { payBillView = bank.PayBillsPost(sessionUserID, models); } else { return PayBills(); } return View(payBillView); }
/*PayBillsGet *CREATES VIEWMODEL FOR USER TO FILL IN DETAILS OF THE SCHEDULED JOB * This is triggered when the user chooses 'Pay Bills' from the dropdown list on the ATM page * The purpose of this method is to create a viewmodel For the view that the user fills in the details to * schedule an automated billpay Job * Eg) a prepopulated viewmodel so the user can choose from dropdown lists of payee and accounts */ public ATMPayBills_ViewModel PayBills(int sessionUserID) { //Find the customer object from EF Customer customerQuery = Repo.GetCustomerSingle(sessionUserID); //Search the Accounts table and return all the accounts objects that match the customerID of the current user IQueryable<Account> accountQuery = Repo.GetCustomerAccountQueryable(sessionUserID); IQueryable<Payee> allPayeeQuery = Repo.GetAllPayeeQueryable(); //Creates an list of accounts owned by the user for them to select to conduct automatic billpay job 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 }); //Creates an list of Payees for the viewModel so the user can choose the payee from the dropdownlist IEnumerable<SelectListItem> AllPayee = allPayeeQuery.OrderBy(p => p.PayeeID).ToList().Select(p => new SelectListItem { Value = Convert.ToString(p.PayeeID), Text = (p.PayeeID + " - " + p.PayeeName) }); //create a prepoluated viewmodel with list information from payee and accounts var newModel = new ATMPayBills_ViewModel() { CustomerName = customerQuery.CustomerName, AccountList = accounts, AllPayeeList = AllPayee, ScheduledDate = System.DateTime.Now }; return newModel; }