Ejemplo n.º 1
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;
        }
Ejemplo n.º 2
0
 partial void UpdateChecksMenuProduct(ChecksMenuProduct instance);
Ejemplo n.º 3
0
 partial void DeleteChecksMenuProduct(ChecksMenuProduct instance);
Ejemplo n.º 4
0
 partial void InsertChecksMenuProduct(ChecksMenuProduct instance);