public static menu_item filterMenuItem(order_item oi) { menu_item mi = (menu_item)db.menu_item.Find(oi.menu_item_id); mi.item = filterItem(mi); return mi; }
public OrderItemVM(order_item oi, menu_item mi, side si) { id = oi.id; this.order_item = oi; this.menu_item = mi; order_item_status = (int)oi.order_item_status; this.side = si; }
public ActionResult Create(order_item order_item) { if (ModelState.IsValid) { db.order_item.Add(order_item); db.SaveChanges(); orderOM.edit(db.orders.Find(order_item.order_id)); return RedirectToAction("Index"); } ViewBag.Error = Global.ServerError; ViewBag.menu_item_id = new SelectList(db.menu_item, "id", "id", order_item.menu_item_id); ViewBag.order_id = new SelectList(db.orders, "id", "id", order_item.order_id); return View(order_item); }
public Boolean edit(order_item order_item) { Order_ItemIM im = new Order_ItemIM(db); OrderOM orderOM = new OrderOM(db); order_item dbVersion = im.find(order_item.id); if (dbVersion.version == order_item.version) { ((IObjectContextAdapter)db).ObjectContext.Detach(dbVersion); db.Entry(order_item).State = EntityState.Modified; order_item.version = order_item.version + 1; db.SaveChanges(); orderOM.edit(db.orders.Find(order_item.order_id)); return true; } return false; }
public void AddMenuItem(menu_item mi, side si, OrderStatusHelper.OrderItemStatusEnum orderItemStatus) { order_item oi = new order_item(); oi.menu_item_id = mi.id; if (si.id == -1) { oi.sides_id = null; } else { oi.sides_id = si.id; } oi.id = uniqueId--; oi.order_id = this.id; oi.order_item_status = (int)orderItemStatus; this.order_item.Add(oi); if (this.total == null) this.total = (decimal)0.0; this.total += mi.price; }
public static void MyClassInitialize(TestContext testContext) { //Add test data (order specific) testDatabase = new TestDatabaseHelper(); restaurant1 = testDatabase.AddRestaurant(); table1 = testDatabase.AddTable(restaurant1); user1 = testDatabase.AddUser("*****@*****.**", table1, (int)SiteRoles.Customer); order1 = testDatabase.AddOrder(table1); item1 = testDatabase.AddItem(); category1 = testDatabase.AddCategory(); menu1 = testDatabase.AddMenu(restaurant1); menuCategory1 = testDatabase.AddMenuCategory(category1, menu1); menuItem1 = testDatabase.AddMenuItem(item1, menuCategory1); orderItem1 = testDatabase.AddOrderItem(order1, menuItem1); //Session db = new touch_for_foodEntities(); ReviewController target = new ReviewController(); Session session = new Session(db, target); session.simulateLogin(user1.username, user1.password); }
public void MyTestInitialize() { //Add test data (order specific) db = new touch_for_foodEntities(); menuItem1 = testDatabase.AddMenuItem(item1, menuCategory1); orderItem1 = testDatabase.AddOrderItem(order1, menuItem1); reviewOrderItem1 = testDatabase.AddReviewOrderItem(review1, orderItem1, "testing1", 2); reviewOrderItem2 = testDatabase.AddReviewOrderItem(review1, orderItem1, "testing2", 3); //set parameters for menuItem2 menuItem2 = new menu_item(); menuItem2.item_id = item1.id; menuItem2.menu_category_id = menuCategory1.id; menuItem2.price = new decimal(10.99); menuItem2.is_active = false; menuItem2.is_deleted = false; }
public ActionResult Edit(order_item order_item) { if (ModelState.IsValid) { try { if (om.edit(order_item)) return RedirectToAction("Index"); else { ViewBag.Error = lockError; } } catch (Exception) { ViewBag.Error = Global.ServerError; } } else { ViewBag.Error = Global.ServerError; } ViewBag.menu_item_id = new SelectList(db.menu_item, "id", "id", order_item.menu_item_id); ViewBag.order_id = new SelectList(db.orders, "id", "id", order_item.order_id); return View(order_item); }
/** * Filters the categories and only returns those that are not already assigned to the menu * that is passed in. * */ public static side filterSide(order_item oi) { side si = (side)db.sides.Find(oi.sides_id); return si; }
public void MyTestInitialize() { //Add test data (order specific) category1 = testDatabase.AddCategory(); restaurant1 = testDatabase.AddRestaurant(); menu1 = testDatabase.AddMenu(restaurant1); menuCategory1 = testDatabase.AddMenuCategory(category1, menu1); table1 = testDatabase.AddTable(restaurant1); order1 = testDatabase.AddOrder(table1); item1 = testDatabase.AddItem(category1); menuItem1 = testDatabase.AddMenuItem(item1, menuCategory1); orderItem1 = testDatabase.AddOrderItem(order1, menuItem1); }
public void MyTestInitialize() { //Add test data (order specific) orderItem1 = testDatabase.AddOrderItem(order1, menuItem1); orderItem2 = testDatabase.AddOrderItem(order1, menuItem1); orderItem3 = new order_item(); orderItem3.menu_item_id = menuItem1.id; orderItem3.order_id = order1.id; }
public void MyTestInitialize() { bill1 = testDatabase.AddBill(order1); orderItem1 = testDatabase.AddOrderItem(order1, bill1, menuItem1); }
public void MyTestInitialize() { //Add test data (order specific) db = new touch_for_foodEntities(); side1 = testDatabase.AddSide(menuCategory1); orderItem1 = testDatabase.AddOrderItem(order1, menuItem1); //set parameters for menuItem2 side2 = new side(); //side2.menu_category = menuCategory1; // This breaks CreateTest side2.menu_category_id = menuCategory1.id; side2.name = "TestingSide"; side2.is_active = false; side2.is_deleted = false; }
/// <summary> /// Removes an order item from the database. /// </summary> /// <param name="orderEntity">Order item to be removed.</param> public void RemoveOrderItem(order_item orderItem) { db = new touch_for_foodEntities(); if(db.order_item.Find(orderItem.id) != null) { db.order_item.Remove(db.order_item.Find(orderItem.id)); db.SaveChanges(); } db.Dispose(); }
public review_order_item AddReviewOrderItem(review r, order_item oi, string text, int rating) { //Initialise db = new touch_for_foodEntities(); review_order_item testReviewOI = new review_order_item(); //Set attributes testReviewOI.rating = rating; testReviewOI.order_item_id = oi.id; testReviewOI.review_id = r.id; testReviewOI.submitted_on = System.DateTime.Now; testReviewOI.rating = 0; //Save db.review_order_item.Add(testReviewOI); db.SaveChanges(); db.Dispose(); return testReviewOI; }
/// <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; }