private void cleanUpOrderItem(bill bill) { bill theBill = db.bills.Find(bill.id); foreach (order_item oi in theBill.order_item) { oi.bill_id = null; } db.SaveChanges(); }
public static void Update(ref bill theBill) { theBill.total = 0; theBill.tps = 0; theBill.tvq = 0; foreach (order_item oi in theBill.order_item) { theBill.total += oi.menu_item.price; } theBill.tps = theBill.total * GetTPS(); theBill.tvq = (theBill.total + theBill.tps) * GetTVQ(); }
public static bool CheckFullyPaid(bill theBill) { bool fullyPaid = true; foreach (order_item oi in theBill.order.order_item) { if (oi.order_item_status != (int)OrderStatusHelper.OrderItemStatusEnum.PAID) { fullyPaid = false; break; } } return fullyPaid; }
public Boolean edit(bill bill) { BillIM im = new BillIM(db); bill dbVersion = im.find(bill.id); if (dbVersion.version == bill.version) { ((IObjectContextAdapter)db).ObjectContext.Detach(dbVersion); db.Entry(bill).State = EntityState.Modified; bill.version = bill.version + 1; db.SaveChanges(); return true; } return false; }
public void MyTestInitialize() { bill1 = testDatabase.AddBill(order1); orderItem1 = testDatabase.AddOrderItem(order1, bill1, menuItem1); }
/// <summary> /// Adds a bill entry to the database /// </summary> /// <param name="orderEntity">The associated order</param> /// <returns>The created bill entity.</returns> internal bill AddBill(order orderEntity) { //Initialise db = new touch_for_foodEntities(); bill testBill = new bill(); //Set attributes testBill.order_id = orderEntity.id; testBill.is_deleted = false; //Save db.bills.Add(testBill); db.SaveChanges(); db.Dispose(); return testBill; }
///<summary> /// Removes a bill from the database. /// </summary> /// <param name="billEntity">Bill to be removed.</param> public void RemoveBill(bill billEntity) { db = new touch_for_foodEntities(); if (db.bills.Find(billEntity.id) != null) { db.bills.Remove(db.bills.Find(billEntity.id)); db.SaveChanges(); } db.Dispose(); }
/// <summary> /// Creates an entry of type order item in the database. /// </summary> /// <param name="orderEntity">Order that order items belongs to.</param> /// <param name="billEntity">Bill that order item belongs to.</param> /// <returns>The created order item entity.</returns> public order_item AddOrderItem(order orderEntity, bill billEntity, menu_item menuItem) { //Initialise db = new touch_for_foodEntities(); order_item testOrderItem = new order_item(); //Set Attributes testOrderItem.order_id = orderEntity.id; testOrderItem.bill_id = billEntity.id; testOrderItem.menu_item_id = menuItem.id; testOrderItem.version = 1; //Save db.order_item.Add(testOrderItem); db.SaveChanges(); db.Dispose(); return testOrderItem; }
public ActionResult Edit(bill bill) { if (ModelState.IsValid) { try { if (om.edit(bill)) return RedirectToAction("Index"); else { ViewBag.Error = lockError; } } catch (Exception) { ViewBag.Error = Global.ServerError; } } else { ViewBag.Error = Global.ServerError; } ViewBag.order_id = new SelectList(db.orders, "id", "id", bill.order_id); return View(bill); }
public int CreateBillForOrder(int id) { order theOrder = orderIM.find(id); if (!Util.Bill.BillUtil.CheckItemsRemaining(theOrder)) return 0; bill newBill = new bill(); newBill.order_id = id; newBill.paid = false; newBill.timestamp = DateTime.Now; newBill.total = 0; newBill.tps = 0; newBill.tvq = 0; Create(newBill); return (newBill.id > 0) ? 1 : 0; }
public ActionResult Create(bill bill) { if (ModelState.IsValid) { try { db.bills.Add(bill); db.SaveChanges(); return RedirectToAction("Index"); } catch (Exception) { } } ViewBag.Error = Global.ServerError; ViewBag.order_id = new SelectList(db.orders, "id", "id", bill.order_id); return View(bill); }
public static decimal GetTotalBeforeTax(bill theBill) { return (decimal)theBill.total; }
public static decimal GetTotalAfterTax(bill theBill) { return (decimal)(theBill.total + theBill.tvq + theBill.tps); }