Esempio n. 1
0
 public Int32 AddNewTableOrder(Int32 tableId) {
     Int32 retVal = 0;
     TableOrder tableOrder = new TableOrder();
     if (tableId != 0) {
         using (menuzRusDataContext db = new menuzRusDataContext(base.connectionString)) {
             tableOrder = db.TableOrders.FirstOrDefault(m => m.TableId == tableId && m.Status != (Int32)Common.TableOrderStatus.Closed); // Нет открытых столов
             if (tableOrder == default(TableOrder)) {
                 tableOrder = new TableOrder();
                 tableOrder.TableId = tableId;
                 db.TableOrders.InsertOnSubmit(tableOrder);
             }
             tableOrder.Status = (Int32)Common.TableOrderStatus.Open;
             tableOrder.DateModified = DateTime.UtcNow;
             db.SubmitChanges();
             retVal = tableOrder.id;
         }
     }
     return retVal;
 }
Esempio n. 2
0
        public Boolean UpdateTableStatus(Int32 tableOrderId, Common.TableOrderStatus status) {
            TableOrder query = new TableOrder();
            if (tableOrderId != 0) {
                using (menuzRusDataContext db = new menuzRusDataContext(base.connectionString)) {
                    query = db.TableOrders.FirstOrDefault(m => m.id == tableOrderId);
                    if (query != default(TableOrder)) {
                        query.Status = (Int32)status;
                        db.SubmitChanges();
                        return true;
                    }
                }
            }

            return false;
        }
Esempio n. 3
0
        public ChecksMenu SaveMenuItem(Item menuItem, Int32 tableId, Int32 orderId, Int32 userId) {
            ItemService _itemService = new ItemService();
            InventoryService _inventoryService = new InventoryService();

            ChecksMenu orderCheckMenu;
            try {
                using (menuzRusDataContext db = new menuzRusDataContext(base.connectionString)) {
                    // New order
                    TableOrder tableOrder = db.TableOrders.FirstOrDefault(m => m.TableId == tableId && m.Status != (Int32)Common.TableOrderStatus.Closed);
                    if (tableOrder == default(TableOrder)) {
                        tableOrder = new TableOrder();
                        tableOrder.TableId = tableId;
                        tableOrder.Status = (Int32)Common.TableOrderStatus.Open;
                        db.TableOrders.InsertOnSubmit(tableOrder);
                        db.SubmitChanges();
                    }

                    Check orderCheck = db.Checks.FirstOrDefault(m => m.id == orderId);
                    if (orderCheck == default(Check)) {
                        orderCheck = new Check();
                        orderCheck.TableOrderId = tableOrder.id;
                        orderCheck.Type = (Int32)Common.CheckType.Guest;
                        orderCheck.Status = (Int32)Common.CheckStatus.Active;
                        orderCheck.UserId = userId;
                        db.Checks.InsertOnSubmit(orderCheck);
                        db.SubmitChanges();
                    }

                    orderCheckMenu = new ChecksMenu();
                    orderCheckMenu.CheckId = orderCheck.id;
                    orderCheckMenu.MenuId = menuItem.id;
                    orderCheckMenu.Status = (Int32)Common.MenuItemStatus.Active;
                    db.ChecksMenus.InsertOnSubmit(orderCheckMenu);
                    db.SubmitChanges();

                    foreach (ItemProduct itemProduct in menuItem.ItemProducts) {
                        ChecksMenuProduct product = new ChecksMenuProduct();
                        product.CheckMenuId = orderCheckMenu.id;
                        product.ItemId = itemProduct.id;
                        db.ChecksMenuProducts.InsertOnSubmit(product);
                        db.SubmitChanges();
                        if (itemProduct.ItemProductAssociations.Count() > 0) {
                            ChecksMenuProductItem item = new ChecksMenuProductItem();
                            item.ProductId = product.id;
                            item.ItemId = itemProduct.ItemProductAssociations[0].id;
                            db.ChecksMenuProductItems.InsertOnSubmit(item);
                            db.SubmitChanges();
                        }
                    }
                }
            }
            catch (Exception ex) {
                return null;
            }
            return orderCheckMenu;
        }
Esempio n. 4
0
 public TableOrder GetTableOrder(Int32 tableId) {
     TableOrder tableOrder = new TableOrder();
     if (tableId != 0) {
         menuzRusDataContext db = new menuzRusDataContext(base.connectionString);
         tableOrder = db.TableOrders.FirstOrDefault(m => m.TableId == tableId && m.Status != (Int32)Common.TableOrderStatus.Closed);
         if (tableOrder == default(TableOrder)) {
             tableOrder = db.TableOrders.Where(m => m.TableId == tableId && m.Status == (Int32)Common.TableOrderStatus.Closed).OrderByDescending(m => m.DateModified).FirstOrDefault();
         }
         return tableOrder;
     }
     return null;
 }
 partial void DeleteTableOrder(TableOrder instance);
 partial void UpdateTableOrder(TableOrder instance);
 partial void InsertTableOrder(TableOrder instance);