public ActionResult PayPartial(int id, int[] Paid, string order) { if (Paid != null) { try { // Finding the sold products from the table that are selected to be paid List <ISoldProductModel> fullList = soldProductData.GetByTable(id); // Selection of the order of the list fullList = MainMenuHelper.OrderListSoldProducts(fullList, order); // Moving in the database the selected sold products to a table of all sold products accomplished MainMenuHelper.PaySelectedSoldProducts(fullList, Paid, soldProductData, soldProductAccomplishedData); //if the table is without any product set it to empty if (fullList.Count() < 1) { ITableModel table = tableData.FindById(id); table.Occupied = false; tableData.Update(table); } } catch (Exception ex) { log.Error("Could't load sold products or tables from Database", ex); return(View("ErrorRetriveData")); } } return(RedirectToAction("Tables")); }
// Menu where is a table with its products and available categories of products public ActionResult TableCategories(int?id, string order) { if (id != null) { try { // Joining list of categories and selected table to a single model mainPageModel.Categories = categoryData.GetAll().OrderBy(x => x.Name).ToList(); ITableModel table = tableData.FindById((int)id); if (table == null) { log.Error("Could't find a table in the Database - return null"); return(View("ErrorTable")); } // Selection of the order of the list table.SoldProducts = MainMenuHelper.OrderListSoldProducts(table.SoldProducts, order); mainPageModel.Tables.Add(table); } catch (Exception ex) { log.Error("Could't load categories or tables from Database", ex); return(View("ErrorRetriveData")); } return(View(mainPageModel)); } else { log.Error("The table ID was null while trying to access"); return(View("ErrorTable")); } }
// It shows a menu where is the list of all products on a table that can be selected for payment public ActionResult PayPartial(int?id, string order) { if (id != null) { try { // Finding the selected table is order to list the Sold Products on it ITableModel table = tableData.FindById((int)id); // Selection of the order of the list table.SoldProducts = MainMenuHelper.OrderListSoldProducts(table.SoldProducts, order); table.OrderSoldProducts = order; return(View(table)); } catch (Exception ex) { log.Error("Could't load tables from Database", ex); return(View("ErrorRetriveData")); } } else { log.Error("The table ID was null while trying to access"); return(View("ErrorTable")); } }