public JsonResult OrderMenuItem(Int32 id, Int32 checkId, Int32 tableId) { Services.Item item; ChecksMenu menu = null; try { item = _itemService.GetItem(id); if (item != null) { menu = _orderService.SaveMenuItem(item, tableId, checkId, SessionData.user.id); } if (menu != null) { var retVal = new { html = ShowMenuItem(id, menu), checkId = menu.CheckId }; return(new JsonResult() { Data = retVal, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } } catch (Exception ex) { } finally { } return(null); }
public Boolean DeleteMenu(Int32 id) { ItemService _itemService = new ItemService(); InventoryService _inventoryService = new InventoryService(); try { using (menuzRusDataContext db = new menuzRusDataContext(base.connectionString)) { ChecksMenu menuItem = db.ChecksMenus.FirstOrDefault(m => m.id == id); if (menuItem != default(ChecksMenu)) { db.ChecksMenus.DeleteOnSubmit(menuItem); IEnumerable <ChecksMenuProduct> products = db.ChecksMenuProducts.Where(m => m.CheckMenuId == id); if (products.Any()) { db.ChecksMenuProducts.DeleteAllOnSubmit(products); foreach (ChecksMenuProduct product in products) { IEnumerable <ChecksMenuProductItem> items = db.ChecksMenuProductItems.Where(m => m.ProductId == product.id); db.ChecksMenuProductItems.DeleteAllOnSubmit(items); } } } db.SubmitChanges(); } } catch (Exception ex) { return(false); } return(true); }
public void UpdateMenuItemStatus(Int32 id, CommonUnit.MenuItemStatus status) { try { using (menuzRusDataContext db = new menuzRusDataContext(base.connectionString)) { ChecksMenu menuItem = db.ChecksMenus.FirstOrDefault(m => m.id == id); if (menuItem != default(ChecksMenu)) { menuItem.Status = (Int32)status; db.SubmitChanges(); } } } catch (Exception ex) { } finally { } }
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)); }
public Boolean DeleteInventoryRegistry(ItemInventoryAssociation association, ChecksMenu checkMenu, String name) { String comment; Int32 associatedItemId; CommonUnit.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 = CommonUnit.InventoryType.In;; quantity = Math.Abs(association.Quantity); AddItemRegistry(associatedItemId, quantity, type, comment); AddInventoryRegistryCheckMenu(associatedItemId, checkMenu.id); } catch (Exception ex) { return(false); } return(true); }
public Boolean AddInventoryRegistry(ItemInventoryAssociation association, ChecksMenu checkMenu) { String comment; Int32 associatedItemId; CommonUnit.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 = CommonUnit.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 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)CommonUnit.TableOrderStatus.Closed); if (tableOrder == default(TableOrder)) { tableOrder = new TableOrder(); tableOrder.TableId = tableId; tableOrder.Status = (Int32)CommonUnit.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)CommonUnit.CheckType.Guest; orderCheck.Status = (Int32)CommonUnit.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)CommonUnit.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); }