コード例 #1
0
        public async Task <IActionResult> CreateBill(BillViewModel billv)
        {
            var customer = await _repo.Customer.GetWithAccounts(CustomerID);

            var list = await _repo.Payee.GetAll();

            billv.Customer = customer;
            billv.SetPayeeDictionary(list);
            if (!ModelState.IsValid)
            {
                return(View(billv));
            }
            var mod = HttpContext.Session.GetInt32("Mod");

            billv.Billpay.FKAccountNumber = await _repo.Account
                                            .GetByID(billv.SelectedAccount);

            billv.Billpay.FKPayeeID = await _repo.Payee.GetByID(billv.SelectedPayee);

            if (mod != 0)
            {
                var bill = await _repo.BillPay.GetByID((int)mod);

                bill.UpdateBill(billv.Billpay);
                _repo.BillPay.Update(bill);
            }
            else
            {
                _repo.BillPay.Update(billv.Billpay);
            }
            await _repo.SaveChanges();

            ModelState.AddModelError("BillCreatedSuccess", "Bill has been saved.");
            var billviewmodel = new BillViewModel {
                Customer = customer
            };

            billviewmodel.SetPayeeDictionary(list);
            return(View(billviewmodel));
        }
コード例 #2
0
        //Method for preparing create bill page
        //This controller method handles both creation of a new bill
        //and taking a modified bill from the bill schedule page
        //Utilizes the BillViewModel object
        public async Task <IActionResult> CreateBill(int billID = 0)
        {
            HttpContext.Session.SetInt32("Mod", 0);
            ViewData["Mod"] = 0;
            var customer = await _repo.Customer.GetWithAccounts(CustomerID);

            var billviewmodel = new BillViewModel {
                Customer = customer
            };

            if (billID != 0)
            {
                var bill = await _repo.BillPay.GetByID(billID);

                billviewmodel.Billpay = bill;
                HttpContext.Session.SetInt32("Mod", billID);
                ViewData["Mod"] = billID;
            }
            var list = await _repo.Payee.GetAll();

            billviewmodel.SetPayeeDictionary(list);
            return(View(billviewmodel));
        }
コード例 #3
0
        //Method for preparing create bill page
        //This controller method handles both creation of a new bill
        //and taking a modified bill from the bill schedule page
        //Utilizes the BillViewModel object
        public async Task <IActionResult> CreateBill(int billID = 0)
        {
            HttpContext.Session.SetInt32("Mod", 0);
            ViewData["Mod"] = 0;
            var customer = await repo.Customer.GetByID(x => x.CustomerID == CustomerID).Include(x => x.Accounts).FirstOrDefaultAsync();

            var billviewmodel = new BillViewModel {
                Customer = customer
            };

            if (billID != 0)
            {
                var bill = await repo.BillPay.GetByID(x => x.BillPayID == billID).FirstOrDefaultAsync();

                billviewmodel.Billpay = bill;
                HttpContext.Session.SetInt32("Mod", billID);
                ViewData["Mod"] = billID;
            }
            var list = await repo.Payee.GetAll().ToListAsync();

            billviewmodel.SetPayeeDictionary(list);
            return(View(billviewmodel));
        }