Пример #1
0
        // GET: Order/Create
        public ActionResult Create()
        {
            AppContext context = new AppContext();

            if (context.MenuItems.Count() == 0)
            {
                context.MenuItems.Add(new MenuItem()
                {
                    Name = "Purple Nurple"
                });
                context.MenuItems.Add(new MenuItem()
                {
                    Name = "Ghermann's Special"
                });
                context.MenuItems.Add(new MenuItem()
                {
                    Name = "ITS BLüDDDD"
                });
                context.MenuItems.Add(new MenuItem()
                {
                    Name = "The Cleric Beast"
                });
                context.MenuItems.Add(new MenuItem()
                {
                    Name = "Bloody Mary"
                });
                context.SaveChanges();
            }
            ViewBag.MenuItems = context.MenuItems;
            return(View());
        }
Пример #2
0
        // GET: Order
        public ActionResult Index()
        {
            var Orders = new AppContext().Orders.Include("MenuItem").Where(o => !o.Complete);

            ViewBag.Orders = Orders.ToList();
            ViewBag.Count  = Orders.Count();
            return(View());
        }
Пример #3
0
        public ActionResult Complete(int id, FormCollection collection)
        {
            // TODO: Add complete logic here
            AppContext context = new AppContext();
            Order      order   = context.Orders.Find(id);

            order.Complete = true;
            context.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #4
0
        public ActionResult Delete(int id, FormCollection collection)
        {
            // TODO: Add delete logic here
            AppContext context = new AppContext();
            Order      order   = context.Orders.Find(id);

            context.Orders.Remove(order);
            context.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #5
0
        public ActionResult Edit(int id, FormCollection collection)
        {
            AppContext context  = new AppContext();
            Order      order    = context.Orders.Find(id);
            MenuItem   menuItem = context.MenuItems.Find(int.Parse(collection.Get("MenuItem")));

            order.MenuItem = menuItem;
            context.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #6
0
        public ActionResult Create(FormCollection collection)
        {
            // TODO: Add insert logic here
            AppContext context  = new AppContext();
            MenuItem   menuItem = context.MenuItems.Find(int.Parse(collection.Get("MenuItem")));
            Order      order    = context.Orders.Add(new Order()
            {
                MenuItem = menuItem
            });

            context.SaveChanges();
            return(Create());
        }