public ActionResult Tables() { // When you login as cashier, if thr doesn't have table, thn it will go inside this if statement if (Table.GetTables().Count() == 0) { ViewbagError("No have tables"); return(View()); } return(View(Table.GetTables())); }
public ActionResult DeleteUserConfirmed(int id) { // If selected user is admin or cashier, it will show different msg, you can go to the view and see the if statement var checkAdmin = AllUsers.GetUsers().Where(c => c.ID == id && (c.Roles == Roles.Admin || c.Roles == Roles.Cashier)).SingleOrDefault(); var checkCustomer = AllUsers.GetUsers().Where(c => c.ID == id && c.Roles == Roles.Customer).SingleOrDefault(); if (checkAdmin != null) { AllUsers.RemoveUser(checkAdmin); } else if (checkCustomer != null) { // Find which table is reserved by this checkCustomer var checkTable = Table.GetTables().Where(c => c.ID == checkCustomer.ID).SingleOrDefault(); if (checkTable != null) { // Check which order in this table var checkOrder = OrderCart.GetOrderCarts().Where(c => c.TablesID == checkTable.TablesID).ToList(); OrderCart.RemoveRangeOrderCart(checkOrder); checkTable.TotalQuantity = 0; checkTable.TotalAmount = 0; checkTable.TStatus = TStatus.Empty; checkTable.ID = null; Table.UpdateTable(checkTable); AllUsers.RemoveUser(checkCustomer); } else { AllUsers.RemoveUser(checkCustomer); } } return(RedirectToAction("Users")); }
public ActionResult Menu() { // Get the login user id var GetUser = Convert.ToInt32(Session["CustomerID"]); // After login , if category list is empty, thn it will show this error msg if (Category.GetCategories().Count() == 0) { ViewbagError("No have data."); return(View()); } // Find which table foreign key of ID is related to GetUser var checkTable = Table.GetTables().Where(c => c.ID == GetUser).SingleOrDefault(); if (checkTable != null) { // Find which order is related to the checkTable var GetOrderCount = OrderCart.GetOrderCarts().Where(c => c.TablesID == checkTable.TablesID).ToList(); var TotalOrder = 0; double TotalAmount = 0; // Loop over the orders to get the total of order and amount foreach (var item in GetOrderCount) { TotalOrder += item.Quantity; TotalAmount += item.TotalAmount; } ViewBag.MyOrder = TotalOrder; ViewBag.TotalAmount = TotalAmount; } else { ViewBag.MyOrder = 0; } return(View(Category.GetCategories())); }
// GET: Cashier public ActionResult Index() { //var table = db.Table.Include(t => t.User); //return View(table.ToList()); return(View(cashierRepo.GetTables())); }