public Boolean AddInventoryRegistry(ItemInventoryAssociation association, ChecksMenu checkMenu) { String comment; Int32 associatedItemId; Common.InventoryType type; Decimal quantity; try { comment = String.Format("Taken [{0}] from: [{1}]. Check# {2}", association.Quantity, association.Item.Name, checkMenu.CheckId); associatedItemId = association.AssociatedItemId; type = Common.InventoryType.Out; ; quantity = Math.Abs(association.Quantity) * -1; AddItemRegistry(associatedItemId, quantity, type, comment); AddInventoryRegistryCheckMenu(associatedItemId, checkMenu.id); } catch (Exception ex) { return false; } return true; }
public Boolean DeleteInventoryRegistry(ItemInventoryAssociation association, ChecksMenu checkMenu, String name) { String comment; Int32 associatedItemId; Common.InventoryType type; Decimal quantity; try { comment = String.Format("Added [{0}] of [{1}] for: [{2}]. Check# {3}", association.Quantity, name, association.Item.Name, checkMenu.CheckId); associatedItemId = association.AssociatedItemId; type = Common.InventoryType.In; ; quantity = Math.Abs(association.Quantity); AddItemRegistry(associatedItemId, quantity, type, comment); AddInventoryRegistryCheckMenu(associatedItemId, checkMenu.id); } catch (Exception ex) { return false; } return true; }
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; }
public String ShowMenuItem(Int32 id, ChecksMenu menuItem) { CheckMenuItem menu = new CheckMenuItem(); try { Services.Item Item = _itemService.GetItem(id); menu.id = menuItem.id; menu.ItemId = Item.id; menu.Name = Item.Name; menu.CheckId = menuItem.CheckId; menu.Price = (Decimal)Item.ItemPrices.OrderByDescending(m => m.DateCreated).Take(1).Select(m => m.Price).FirstOrDefault(); menu.HasProducts = (_orderService.GetProducts(menu.id).Count() > 0); } catch (Exception ex) { base.Log(ex); return String.Empty; } return RenderViewToString(this.ControllerContext, "_OrderMenuItemPartial", menu); }
partial void DeleteChecksMenu(ChecksMenu instance);
partial void UpdateChecksMenu(ChecksMenu instance);
partial void InsertChecksMenu(ChecksMenu instance);