public List<Category> GetMenuCategories(Int32 customerId, Common.CategoryType type, Int32 menuId) { List<CategoryView> retVal; menuzRusDataContext db; try { if (menuId == 0) { // All return (List<Category>)GetCategories(customerId, type); } db = new menuzRusDataContext(base.connectionString); retVal = (from category in GetCategories(customerId, type) select new CategoryView { id = category.id, Name = category.Name, Description = category.Description, Items = (from item in db.Items join menuItem in db.MenuItems on item.id equals menuItem.ItemId where category.id == item.CategoryId && menuItem.MenuId == menuId select item ).ToEntitySet() } ).ToList(); return retVal.Cast<Category>().ToList(); } catch (Exception ex) { } return null; }
public ActionResult EditItem(Int32? id, Common.CategoryType type) { try { return PartialView("_ItemPartial", GetModel(id, type)); } catch (Exception ex) { } finally { } return null; }
public String GetItemComment(Int32 parentId, Common.CommentType type, Int32 customerId) { menuzRusDataContext db = new menuzRusDataContext(base.connectionString); String[] query = (from com in db.Comments join cmc in db.CheckMenuComments on com.id equals cmc.CommentId where com.CustomerId == customerId && cmc.ParentId == parentId && cmc.Type == (Int32)type select com.CommentText).ToArray(); return String.Join(" | ", query); }
public String EditCategory(Int32 id, Common.CategoryType type) { try { return RenderViewToString(this.ControllerContext, "_CategoryPartial", GetModel(id, type)); } catch (Exception ex) { base.Log(ex); } finally { } return null; }
public Int32 SaveComment(Int32 id, Int32 parentId, Common.CommentType type) { CheckMenuComment query = new CheckMenuComment(); try { using (menuzRusDataContext db = new menuzRusDataContext(base.connectionString)) { query.Type = (Int32)type; query.ParentId = parentId; query.CommentId = id; db.CheckMenuComments.InsertOnSubmit(query); db.SubmitChanges(); } } catch (Exception ex) { } return query.id; }
public Boolean DeleteComment(Int32 id, Int32 parentId, Common.CommentType type) { CheckMenuComment query; try { using (menuzRusDataContext db = new menuzRusDataContext(base.connectionString)) { query = db.CheckMenuComments.FirstOrDefault(m => m.CommentId == id && m.ParentId == parentId && m.Type == (Int32)type); if (query != default(CheckMenuComment)) { db.CheckMenuComments.DeleteOnSubmit(query); db.SubmitChanges(); } } } catch (Exception ex) { return false; } return true; }
public Boolean AddItemRegistry(Int32 id, Decimal qty, Common.InventoryType type, String comment) { InventoryRegistry query = new InventoryRegistry(); try { using (menuzRusDataContext db = new menuzRusDataContext(base.connectionString)) { query.Quantity = qty; query.Type = (Int32)type; query.AssociatedItemId = id; query.Comment = comment; db.InventoryRegistries.InsertOnSubmit(query); db.SubmitChanges(); } } catch (Exception ex) { return false; } return true; }
private void SendToLogger(Common.LogType type, Int32 userId, String sessionId, String trace, String route, params Object[] data) { try { using (menuzRusDataContext db = new menuzRusDataContext(base.connectionString)) { Log log = new Log(); log.IP = Common.GetIP(); log.LogType = (Int32)type; log.UserId = userId; log.SessionId = sessionId != null ? sessionId : "N/A"; log.Trace = String.Format("{0}{1}", trace, BuildParameters(data)); log.Route = route; db.Logs.InsertOnSubmit(log); db.SubmitChanges(); } } catch (Exception ex) { throw ex; } }
public List<Category> GetCategories(Int32 customerId, Common.CategoryType type, String search) { List<Category> retVal; menuzRusDataContext db = new menuzRusDataContext(base.connectionString); try { retVal = db.Categories.Where(m => m.CustomerId == customerId && m.Status == (Int32)Common.Status.Active && m.Type == (Int32)type).ToList(); if (!String.IsNullOrEmpty(search)) { retVal = (from c in retVal where c.Name.ToUpper().Contains(search) || (c.Items.Where(m => m.Name.ToUpper().Contains(search) || m.Description.toUpper().Contains(search)).Any()) select c).ToList(); } } catch (Exception ex) { throw ex; } return retVal; }
public List<CommentUnion> GetComments(Int32 customerId, Int32 parentId, Common.CommentType type) { menuzRusDataContext db = new menuzRusDataContext(base.connectionString); CheckMenuComment checkMenuComment; List<CommentUnion> retVal = new List<CommentUnion>(); IEnumerable<Comment> comments = db.Comments.Where(m => m.CustomerId == customerId); IEnumerable<CheckMenuComment> checkMenuComments = db.CheckMenuComments.Where(m => m.ParentId == parentId && m.Type == (Int32)type); foreach (Comment comment in comments) { CommentUnion comm = new CommentUnion(); comm.id = comment.id; comm.CommentText = comment.CommentText; comm.ParentId = 0; comm.Selected = false; checkMenuComment = checkMenuComments.FirstOrDefault(m => m.CommentId == comment.id); if (checkMenuComment != default(CheckMenuComment)) { comm.ParentId = checkMenuComment.ParentId; comm.Selected = true; } retVal.Add(comm); } return retVal; }
private CommentsModel GetModel(Int32 parentId, Common.CommentType type) { CommentsModel model = new CommentsModel(); model.Comments = new List<Models.Comment>(); try { List<CommentUnion> comments = _commentService.GetComments(SessionData.customer.id, parentId, type); foreach (CommentUnion comment in comments) { Models.Comment comm = new Models.Comment(); comm.id = comment.id; comm.ParentId = comment.ParentId; comm.CommentText = comment.CommentText; comm.Selected = comment.Selected; model.Comments.Add(comm); } } catch (Exception ex) { base.Log(ex); } finally { } return model; }
public void Log(Common.LogType logType, Int32 userId, String sessionId, params Object[] data) { SendToLogger(logType, userId, sessionId, null, null, data); }
public void Log(Common.LogType logType, Int32 userId, String sessionId, String trace, String route, params Object[] data) { SendToLogger(logType, userId, sessionId, trace, route, data); }
private CategoryModel GetModel(Int32 id, Common.CategoryType type) { CategoryModel model; Services.Category category; try { model = new CategoryModel(); model.id = id; model.Type = type; model.Status = Common.Status.Active; //set for new or existing category category = _categoryService.GetCategory(id); if (category != null) { model.id = category.id; model.Name = category.Name; model.Description = category.Description; model.Status = (Common.Status)category.Status; model.Type = (Common.CategoryType)category.Type; model.ImageUrl = category.ImageUrl; } return model; } catch (Exception ex) { base.Log(ex); } finally { } return null; }
public JsonResult SaveItem(Int32 checkId, Int32 productId, Int32 knopaId, Common.ProductType type) { try { _orderService.SaveItem(productId, knopaId, type); } catch (Exception ex) { base.Log(ex); } finally { } var retVal = new { }; return Json(retVal); }
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; }
public JsonResult UpdateCheckStatus(Int32 checkId, Common.CheckType type, Common.CheckStatus status, Decimal adjustment, Int32 split) { CheckPrint model; try { if (status == Common.CheckStatus.Paid) { model = GetCheckPrintModel(checkId, type.ToString(), status.ToString(), split, adjustment); if (model != null) _orderService.UpdateCheckStatusPaid(checkId, model.Summary, model.Tax, model.Adjustment); } else { _orderService.UpdateCheckStatus(checkId, status); } } catch (Exception ex) { base.Log(ex); } finally { } var retVal = new { }; return Json(retVal); }
public void SaveItem(Int32 productId, Int32 knopaId, Common.ProductType type) { ItemService _itemService = new ItemService(); InventoryService _inventoryService = new InventoryService(); ChecksMenuProductItem query = null; if (productId != 0 && knopaId != 0) { using (menuzRusDataContext db = new menuzRusDataContext(base.connectionString)) { if (type == Common.ProductType.Alternatives) { query = db.ChecksMenuProductItems.FirstOrDefault(m => m.ProductId == productId); if (query != default(ChecksMenuProductItem)) { query.ItemId = knopaId; } } else if (type == Common.ProductType.Addons) { query = db.ChecksMenuProductItems.FirstOrDefault(m => m.ProductId == productId && m.ItemId == knopaId); if (query == default(ChecksMenuProductItem)) { query = new ChecksMenuProductItem(); query.ItemId = knopaId; query.ProductId = productId; db.ChecksMenuProductItems.InsertOnSubmit(query); } else { db.ChecksMenuProductItems.DeleteOnSubmit(query); } } db.SubmitChanges(); } } }
public void Log(Common.LogType logType) { LogData(logType); }
private ItemModel GetModel(Int32? id, Common.CategoryType type) { ItemModel model = new ItemModel(); Item item; try { model.Categories = _categoryService.GetCategories(SessionData.customer.id, type); if (model.Categories.Any()) { model.CategoryId = model.Categories[0].id; } model.Status = Common.Status.Active; model.CategoryType = type; if (id.HasValue) { item = _itemService.GetItem((Int32)id.Value); if (item != null) { model.Status = (Common.Status)item.Status; model.id = item.id; model.CategoryId = item.CategoryId; model.Name = item.Name; model.Description = item.Description; model.ImageUrl = item.ImageUrl; model.ItemPrices = _itemService.GetItemPrices(model.id); model.InventoryRegistries = item.InventoryRegistries.Where(m => m.DateCreated > DateTime.Now.AddDays(-7)).ToList(); model.ItemInventoryAssociations = item.ItemInventoryAssociations.ToList(); model.UOM = (Common.UOM)item.UOM; model.Price2Add = (model.ItemPrices.Any() ? model.ItemPrices[0].Price : 0); } } return model; } catch (Exception ex) { base.Log(ex); } finally { } return null; }
public Boolean UpdateCheckStatus(Int32 checkId, Common.CheckStatus status) { Check query = new Check(); Printout kitchenOrder; if (checkId != 0) { using (menuzRusDataContext db = new menuzRusDataContext(base.connectionString)) { query = db.Checks.FirstOrDefault(m => m.id == checkId); if (query != default(Check)) { query.Status = (Int32)status; if (status == Common.CheckStatus.Ordered) { // Run Inventory UpdateInventory(checkId); kitchenOrder = db.Printouts.FirstOrDefault(m => m.CheckId == checkId); if (kitchenOrder == default(Printout)) { kitchenOrder = new Printout(); } kitchenOrder.Status = (Int32)Common.PrintStatus.Queued; kitchenOrder.Type = (Int32)Common.PrintType.KitchenOrder; kitchenOrder.CheckId = checkId; if (kitchenOrder.id == 0) { db.Printouts.InsertOnSubmit(kitchenOrder); } } db.SubmitChanges(); return true; } } } return false; }
public Boolean UpdateCheckType(Int32 checkId, Common.CheckType type) { Check query = new Check(); if (checkId != 0) { using (menuzRusDataContext db = new menuzRusDataContext(base.connectionString)) { query = db.Checks.FirstOrDefault(m => m.id == checkId); if (query != default(Check)) { query.Type = (Int32)type; db.SubmitChanges(); return true; } } } return false; }
public String GetSettings(Int32 id, Common.Settings type) { menuzRusDataContext db = new menuzRusDataContext(base.connectionString); return db.Settings.Where(m => m.CustomerId == id && m.Type == type.ToString()).Select(m => m.Value).FirstOrDefault(); }
private Boolean SaveSetting(Common.Settings type, String value) { Setting setting; try { setting = new Setting(); setting.Type = type.ToString(); setting.Value = value; if (!_settingsService.SaveSetting(setting, SessionData.customer.id)) { base.Log(SessionData.exception); return false; } } catch (Exception ex) { base.Log(ex); return false; } finally { } return true; }
public void Log(Common.LogType logType, String trace) { LogData(logType, trace); }
public JsonResult UpdateTableStatus(Int32 tableOrderId, Common.TableOrderStatus status) { try { _orderService.UpdateTableStatus(tableOrderId, status); } catch (Exception ex) { base.Log(ex); } finally { } var retVal = new { }; return Json(retVal); }
public List<Category> GetCategories(Int32 customerId, Common.CategoryType type) { return GetCategories(customerId, type, null); }
public JsonResult UpdateCheckType(Int32 checkId, Common.CheckType type) { try { _orderService.UpdateCheckType(checkId, type); } catch (Exception ex) { base.Log(ex); } finally { } var retVal = new { }; return Json(retVal); }
private void AddItemRegistry(Int32 id, Decimal qty, Common.InventoryType type, String comment) { try { _inventoryService.AddItemRegistry(id, qty, type, comment); } catch (Exception ex) { base.Log(ex); } finally { } }
public void UpdateMenuItemStatus(Int32 id, Common.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 { } }