Exemplo n.º 1
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);

            }
        }
Exemplo n.º 2
0
        //Used to modify the job and time if a user modifys it
        //Used to update the db and schedule service
        public void ModifyJob(BillPay UpdatedBillPayObject)
        {
            Debug.WriteLine("Inside Modify Job Method");
            //Remove old job from the schduler
            removeJob(UpdatedBillPayObject.BillPayID.ToString());

            //Add new job to schduler
            createScheduledJobService(UpdatedBillPayObject.BillPayID, UpdatedBillPayObject.AccountNumber,
                UpdatedBillPayObject.PayeeID, UpdatedBillPayObject.Amount, UpdatedBillPayObject.Period[0], UpdatedBillPayObject.ScheduleDate);
        }
Exemplo n.º 3
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;
        }