public ActionResult Create([Bind(Include = "TableId,TableStatus")] TableModel tableModel) { if (ModelState.IsValid) { db.Tables.Add(tableModel); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tableModel)); }
public ActionResult Create([Bind(Include = "ProductOrderId,ProductOrderStatus")] ProductOrderModel productOrderModel) { if (ModelState.IsValid) { db.ProductOrders.Add(productOrderModel); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(productOrderModel)); }
public ActionResult Create([Bind(Include = "ProductId,Name,Price,ProductType")] ProductModel productModel) { if (ModelState.IsValid) { db.Products.Add(productModel); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(productModel)); }
public ActionResult Create([Bind(Include = "UserId,Email,Password")] UserModel userModel) { if (ModelState.IsValid) { db.Users.Add(userModel); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(userModel)); }
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)); }
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")); } }