Ejemplo n.º 1
0
 public ActionResult Edit([Bind(Include = "TableId,TableStatus")] TableModel tableModel)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tableModel).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tableModel));
 }
Ejemplo n.º 2
0
 public ActionResult Edit([Bind(Include = "ProductOrderId,ProductOrderStatus")] ProductOrderModel productOrderModel)
 {
     if (ModelState.IsValid)
     {
         db.Entry(productOrderModel).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(productOrderModel));
 }
Ejemplo n.º 3
0
 public ActionResult Edit([Bind(Include = "UserId,Email,Password")] UserModel userModel)
 {
     if (ModelState.IsValid)
     {
         db.Entry(userModel).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(userModel));
 }
Ejemplo n.º 4
0
 public ActionResult Edit([Bind(Include = "ProductId,Name,Price,ProductType")] ProductModel productModel)
 {
     if (ModelState.IsValid)
     {
         productModel.Availability    = 10;
         db.Entry(productModel).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(productModel));
 }
Ejemplo n.º 5
0
        public ActionResult Create([Bind(Include = "OrderId,OrderStatus,TimeStamp,Table,Tables,TableIds")] OrderViewModel orderViewModel)
        {
            if (orderViewModel.TableIds == null)
            {
                TempData["ErrorMessage"] = "Je moet mininaal één tafel selecteren";
                return(RedirectToAction("Create"));
            }
            if (ModelState.IsValid)
            {
                OrderModel order = new OrderModel
                {
                    TimeStamp = orderViewModel.TimeStamp,
                    Products  = new List <ProductOrderModel>(),
                    Tables    = new List <TableModel>()
                };
                //foreach (int prod in orderViewModel.ProductIds)
                //{
                //    ProductOrderModel productOrder = new ProductOrderModel()
                //    {
                //        Product = db.Products.First(x => x.ProductId == prod),
                //        ProductOrderStatus = Status.Preparing,
                //    };
                //    order.Products.Add(productOrder);
                //    ProductModel product = db.Products.First(x => x.ProductId == prod);
                //    product.Availability -= 1;
                //    db.Entry(product).State = EntityState.Modified;
                //    db.SaveChanges();
                //}
                order.Tables.AddRange(db.Tables.Where(x => orderViewModel.TableIds.Contains(x.TableId)));
                foreach (var table in db.Tables.Where(x => orderViewModel.TableIds.Contains(x.TableId)))
                {
                    table.TableStatus     = TableModel.TableStat.Bezet;
                    db.Entry(table).State = EntityState.Modified;
                }

                db.Orders.Add(order);
                db.SaveChanges();
                return(RedirectToAction("AddProduct", new { id = order.OrderId }));
            }
            return(View(orderViewModel));
        }
Ejemplo n.º 6
0
        public ActionResult DishDone(int id)
        {
            ProductOrderModel productOrder = db.ProductOrders.Include("Product").First(x => x.ProductOrderId == id);
            FoodType          foodType     = productOrder.Product.ProductType;

            productOrder.ProductOrderStatus = Status.Done;
            db.Entry(productOrder).State    = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();
            if ((int)foodType > 2)
            {
                return(RedirectToAction("Kitchen"));
            }
            else
            {
                return(RedirectToAction("Bar"));
            }
        }