Esempio n. 1
0
        public ActionResult Create(BillViewModel model)
        {
            if (ModelState.IsValid)
            {
                var Db = new ApricotContext();
                FillBillsViewModel fbvm = new FillBillsViewModel(Db);
                fbvm.CreateNewBill(User.Identity.Name, model);

                //Get BillID
                BillDetailRepository billdetailrepo = new BillDetailRepository(Db);
                var billdetail = billdetailrepo.GetAll().Where(bd => (bd.Bill_Date == model.BillDate &&
                                                                      bd.Bill_Type == model.BillType &&
                                                                      bd.Bill_ModeOfPayment == model.ModeOfPayment));
                model.BillID = billdetail.Select(bd => bd.Bill_ID).Single();

                //Create Notification for New Bill
                NotificationBL notibl = new NotificationBL(Db);
                notibl.NotifyManager(model.BillID);

                return(RedirectToAction("Index"));
            }

            //Something Went wrong, redisplay form
            return(View(model));
        }