Esempio n. 1
0
        public ActionResult ViewOrderStatus(int id)
        {
            order order = im.find(id);
            Session["ORDER"] = order;

            OrderVM orderVM = new OrderVM(order);
            if (order != null)
            {
                foreach (order_item oi in order.order_item)
                {
                    menu_item mi = Util.Order.OrderUtil.filterMenuItem(oi);
                    side si = Util.Order.OrderUtil.filterSide(oi);
                    OrderItemVM orderItemVM = new OrderItemVM(oi, mi, si);
                    orderVM.addItem(orderItemVM);
                }
            }

            return View("OrderUserDetails", orderVM);
        }
Esempio n. 2
0
        public ActionResult Finalize()
        {
            order currentOrder = (order)Session["ORDER"];
            if (currentOrder == null)
            {
                user authUser = Util.User.UserUtil.getAuthenticatedUser(Request);
                if (authUser == null) return RedirectToAction("ViewFromSession"); // failure
                currentOrder = Util.Session.SessionUtil.getOpenOrder(authUser);
            }

            Session["ORDER"] = null;
            if (currentOrder == null)
            {
                // no order in session
                return RedirectToAction("ViewFromSession");
            }
            if (currentOrder.order_item.Count == 0)
            {
                if (currentOrder.id > 0)
                {
                    om.delete(currentOrder.id);
                }
                return RedirectToAction("ViewFromSession");
            }
            OrderVM orderVM = new OrderVM(currentOrder);

            if (currentOrder.table_id == null)
            {
                currentOrder.table_id = 1;
            }

            if (currentOrder.order_status == (int)OrderStatusHelper.OrderStatusEnum.OPEN)
            {
                Create(currentOrder);
            }
            else
            {
                currentOrder.order_status = (int)OrderStatusHelper.OrderStatusEnum.PLACED;
                Util.Order.OrderUtil.mergeExistingOrderToDb(currentOrder);
            }

            return  RedirectToAction("ViewFromSession"); //success
        }
Esempio n. 3
0
        public ViewResult ViewFromSession()
        {
            order order = (order)Session["ORDER"];
            if (order == null)
            {
                user authUser = Util.User.UserUtil.getAuthenticatedUser(Request);
                if (authUser == null) return View("ViewFromSession", new OrderVM()); // failure
                order = Util.Session.SessionUtil.getOpenOrder(authUser);
            }

            OrderVM orderVM = new OrderVM(order);
            if (order != null)
            {
                foreach (order_item oi in order.order_item)
                {
                    menu_item mi = Util.Order.OrderUtil.filterMenuItem(oi);
                    side si = Util.Order.OrderUtil.filterSide(oi);
                    OrderItemVM orderItemVM = new OrderItemVM(oi, mi, si);
                    orderVM.addItem(orderItemVM);
                }
            }

            return View(orderVM);
        }
Esempio n. 4
0
        /*public ViewResult RetrieveOrderItems()
        {
            var orders = db.orders.Include(o => o.order_status).Include(o => o.user).Include(o => o.waiter).OrderBy(o => o.table_id).ThenBy(o => o.timestamp);

            return View();
        }  */
        public ActionResult Editing(int id)
        {
            order order = im.find(id);
            Session["ORDER"] = order;

            order.order_status = (int)OrderStatusHelper.OrderStatusEnum.EDITING;
            db.SaveChanges();

            OrderVM orderVM = new OrderVM(order);
            if (order != null)
            {
                foreach (order_item oi in order.order_item)
                {
                    menu_item mi = Util.Order.OrderUtil.filterMenuItem(oi);
                    side si = Util.Order.OrderUtil.filterSide(oi);
                    OrderItemVM orderItemVM = new OrderItemVM(oi, mi, si);
                    orderVM.addItem(orderItemVM);
                }
            }

            return View("ViewFromSession",orderVM);
        }