Exemplo n.º 1
0
        public ActionResult BillScheduleUpdate(ATMPayBillsSchedule_ViewModel models, string id)
        {
            int sessionUserID = WebSecurity.GetUserId(User.Identity.Name);
            Bank bank = new Bank();

            HttpContext.Session["accountNumber"] = models.AccountNumber;

            if (ModelState.IsValid)
            {
                if (id == null)
                {
                  return View(bank.billUpdatePost(sessionUserID, models, null));
                }
                else
                {
                models.message = "Schedule Bill Had Been Updated";
                return View(bank.billUpdatePost(sessionUserID, models, id));
                }
            }
            else
            {
                return BillScheduleUpdate(id);
            }
        }
Exemplo n.º 2
0
        /*PayBillUpdatePost
         *This method actually triggered when the user submit the changes they have made to the schdulked job
         * Method will modify the database and also modify the active billpay job in the schduler
         */
        public ATMPayBillsSchedule_ViewModel billUpdatePost(int sessionID, ATMPayBillsSchedule_ViewModel models, string id)
        {
            int billID = 0;
            if (id != null)
            {
                billID = int.Parse(id);
            }

            //Create a billPayObject instance with newly updated properties
            //and send it to repositry to handle the update to DB.
            BillPay UpdatedBillPayObject = new BillPay();
            DateTime ScheduleDateFormat = DateTime.ParseExact(models.ScheduleDate, "dd/MM/yyyy", CultureInfo.InvariantCulture);

            UpdatedBillPayObject.BillPayID = billID;
            UpdatedBillPayObject.AccountNumber = models.AccountNumber;
            UpdatedBillPayObject.PayeeID = models.PayeeID;
            UpdatedBillPayObject.Amount = models.Amount;
            UpdatedBillPayObject.ScheduleDate = ScheduleDateFormat;
            UpdatedBillPayObject.Period = models.Period;
            UpdatedBillPayObject.ModifyDate = System.DateTime.Now;

            Repo.UpdateExistingBillPayRecord(UpdatedBillPayObject);

            //Tell the schduler to remove the job
            //and now manually create a new job with the newly updated information
            Billpay BillPayBusinessObj = new Billpay();
            BillPayBusinessObj.ModifyJob(UpdatedBillPayObject);

            //######### Repopulating the viewmodel Below ####

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

            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
            });

            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;

            return models;
        }
Exemplo n.º 3
0
        /* PayBillUpdateGet
         * THis method is triggered when the user clicks 'Edit' inside the grid of
         * Scheduled billpay job aligned with the associated job they wish to modify
         *
         * This method will generate the viewmodel to displays the view where the
         * user would like to update the scheduled job
         */
        public ATMPayBillsSchedule_ViewModel billUpdateGet(int sessionID, string id)
        {
            int billID = 0;
            if (id != null)
            {
                billID = int.Parse(id);
            }
            var customerQuery = Repo.GetCustomerSingle(sessionID);
            var accountQuery = Repo.GetCustomerAccountQueryable(sessionID);
            var allPayeeQuery = Repo.GetAllPayeeQueryable();
            var billPayIDQuery = Repo.GetBillPaySingle(billID);

            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)
            });

            var newModel = new ATMPayBillsSchedule_ViewModel()
            {
                CustomerName = customerQuery.CustomerName,
                accountList = accounts,
                AllPayeeList = allPayee,
                AccountNumber = billPayIDQuery.AccountNumber,
                PayeeID = billPayIDQuery.PayeeID,
                Amount = billPayIDQuery.Amount,
                ScheduleDate = billPayIDQuery.ScheduleDate.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture),
                Period = billPayIDQuery.Period,
            };
            return newModel;
        }