Esempio n. 1
0
        public ActionResult PlaceOrder(string id)
        {
            var userName = User.Identity.GetUserName();
            /* Find the details of the customer placing the order*/
            var customer = db.Customers.Where(x => x.Email == userName).FirstOrDefault();

            /* Place the order */
            order_Service.AddOrder(customer);
            /* Get the last placed order by the cus.tomer */
            var order = order_Service.GetOrders()
                        .FindAll(x => x.Email == customer.Email)
                        .OrderByDescending(x => x.date_created)
                        .FirstOrDefault();

            /* If the customer requests delivery, save order address */
            if (id == "deliver")
            {
                address_Service.AddShippingAddress(new Shipping_Address()
                {
                    Order_ID      = order.Order_ID,
                    street_number = Convert.ToInt16(Session["street_number"].ToString()),
                    street_name   = Session["street_name"].ToString(),
                    City          = Session["City"].ToString(),
                    State         = Session["State"].ToString(),
                    ZipCode       = Session["ZipCode"].ToString(),
                    Country       = Session["Country"].ToString(),

                    Building_Name  = "",
                    Floor          = "",
                    Contact_Number = "",
                    Comments       = "",
                    Address_Type   = ""
                });
            }
            /* Migrate cart items to map as order items */
            order_Service.AddOrderItems(order, cart_Service.GetCartItems());
            /* Empty the cart items */
            cart_Service.EmptyCart();
            /* Update Order Tracking Report */
            order_Service.AddOrderTrackingReport(new Order_Tracking()
            {
                order_ID  = order.Order_ID,
                date      = DateTime.Now,
                status    = "Awaiting Payment",
                Recipient = ""
            });


            //Redirect to payment
            return(RedirectToAction("Payment", new { id = order.Order_ID }));
        }
        //Customer orders
        public ActionResult Customer_Orders(string id)
        {
            var userName = User.Identity.GetUserName();

            if (User.IsInRole("Customer"))
            {
                if (String.IsNullOrEmpty(id) || id == "all")
                {
                    ViewBag.Status        = "All";
                    ViewBag.CustomerEmail = User.Identity.GetUserName();
                    return(View(order_Service.GetOrders().Where(x => x.Email == userName)));
                }
                else
                {
                    ViewBag.Status        = id;
                    ViewBag.CustomerEmail = User.Identity.GetUserName();
                    return(View(order_Service.GetOrders(id).Where(x => x.Email == userName)));
                }
            }
            else
            {
                if (String.IsNullOrEmpty(id) || id == "all")
                {
                    ViewBag.Status = "All";
                    return(View(order_Service.GetOrders()));
                }
                else
                {
                    ViewBag.Status = id;
                    return(View(order_Service.GetOrders(id)));
                }
            }
        }
Esempio n. 3
0
        public OrderList(string view)
        {
            //we use view for the names of the forms
            this.view = view;

            InitializeComponent();
            //timer startup for refresh every second
            timer          = new Timer();
            timer.Interval = (1000);
            timer.Tick    += new EventHandler(timer1_Tick);
            timer.Start();
            //get the orders that are not ready
            orders = service.GetOrders();
            foreach (Order order in orders)
            {
                //making sure the order is from today and that it is not ready
                if (order.TimeStamp.Day == DateTime.Today.Day && order.Status == "Not Ready")
                {
                    //go through every table to check if the order belongs to that one
                    if (order.TableID == 1)
                    {
                        lbl_timetbl1.Text = order.TimeStamp.ToString("hh:mm:ss");
                    }
                    else if (order.TableID == 2)
                    {
                        lbl_timetbl2.Text = order.TimeStamp.ToString("hh:mm:ss");
                    }
                    else if (order.TableID == 3)
                    {
                        lbl_timetbl3.Text = order.TimeStamp.ToString("hh:mm:ss");
                    }
                    else if (order.TableID == 4)
                    {
                        lbl_timetbl4.Text = order.TimeStamp.ToString("hh:mm:ss");
                    }
                    else if (order.TableID == 5)
                    {
                        lbl_timetbl5.Text = order.TimeStamp.ToString("hh:mm:ss");
                    }
                    else if (order.TableID == 6)
                    {
                        lbl_timetbl6.Text = order.TimeStamp.ToString("hh:mm:ss");
                    }
                    else if (order.TableID == 7)
                    {
                        lbl_timetbl7.Text = order.TimeStamp.ToString("hh:mm:ss");
                    }
                    else if (order.TableID == 8)
                    {
                        lbl_timetbl8.Text = order.TimeStamp.ToString("hh:mm:ss");
                    }
                    else if (order.TableID == 9)
                    {
                        lbl_timetbl9.Text = order.TimeStamp.ToString("hh:mm:ss");
                    }
                    else if (order.TableID == 10)
                    {
                        lbl_timetbl10.Text = order.TimeStamp.ToString("hh:mm:ss");
                    }
                }
            }
        }
        /// <summary>
        /// when the program is opened
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void KitchenOverview_Load(object sender, EventArgs e)
        {
            labels.Add("name1", lb_NameOrder1);
            labels.Add("name2", lb_NameOrder2);
            labels.Add("name3", lb_NameOrder3);
            labels.Add("name4", lb_NameOrder4);

            labels.Add("table1", lb_TableOrder1);
            labels.Add("table2", lb_TableOrder2);
            labels.Add("table3", lb_TableOrder3);
            labels.Add("table4", lb_TableOrder4);

            labels.Add("time1", lbl_TimeOrder1);
            labels.Add("time2", lbl_TimeOrder2);
            labels.Add("time3", lbl_TimeOrder3);
            labels.Add("time4", lbl_TimeOrder4);

            labels.Add("note1", lb_NoteOrder1);
            labels.Add("note2", lb_NoteOrder2);
            labels.Add("note3", lb_NoteOrder3);
            labels.Add("note4", lb_NoteOrder4);

            listviews.Add("lv1", lv_Order1);
            listviews.Add("lv2", lv_Order2);
            listviews.Add("lv3", lv_Order3);
            listviews.Add("lv4", lv_Order4);

            Label label = labels["name" + 1];

            order1 = new ChapooModels.Order();
            order2 = new ChapooModels.Order();
            order3 = new ChapooModels.Order();
            order4 = new ChapooModels.Order();

            employees = Employee_Service.GetAllEmployees();

            int i = 0;

            Orders = Order_Service.GetOrders(TypeOfView);
            foreach (ChapooModels.Order order in Orders)
            {
                switch (i)
                {
                case 0: order1 = order; break;

                case 1: order2 = order; break;

                case 2: order3 = order; break;

                case 3: order4 = order; break;
                }
                i++;
            }
            Orders.Remove(order1);
            Orders.Remove(order2);
            Orders.Remove(order3);
            Orders.Remove(order4);
            Order(order1, 1);
            Order(order2, 2);
            Order(order3, 3);
            Order(order4, 4);
        }