private CategoryModel GetModel(Int32 id, CommonUnit.CategoryType type) { CategoryModel model; Services.Category category; try { model = new CategoryModel(); model.id = id; model.Type = type; model.Status = CommonUnit.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 = (CommonUnit.Status)category.Status; model.Type = (CommonUnit.CategoryType)category.Type; model.ImageUrl = category.ImageUrl; } return(model); } catch (Exception ex) { base.Log(ex); } finally { } return(null); }
public List <Category> GetMenuCategories(Int32 customerId, CommonUnit.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, CommonUnit.CategoryType type) { try { return(PartialView("_ItemPartial", GetModel(id, type))); } catch (Exception ex) { } finally { } return(null); }
public String EditCategory(Int32 id, CommonUnit.CategoryType type) { try { return(RenderViewToString(this.ControllerContext, "_CategoryPartial", GetModel(id, type))); } catch (Exception ex) { base.Log(ex); } finally { } return(null); }
private ItemModel GetModel(Int32?id, CommonUnit.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 = CommonUnit.Status.Active; model.CategoryType = type; if (id.HasValue) { item = _itemService.GetItem((Int32)id.Value); if (item != null) { model.Status = (CommonUnit.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 = (CommonUnit.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 List <Category> GetCategories(Int32 customerId, CommonUnit.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)CommonUnit.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); }
private DesignerModel GetModel(CommonUnit.CategoryType type, String search) { DesignerModel model = new DesignerModel(); try { search = String.IsNullOrEmpty(search) ? search : search.ToUpper(); model.CategoryType = type; model.Categories = _categoryService.GetCategories(SessionData.customer.id, type, search); model.ItemProducts = null; if (SessionData.item != null) { model.ItemProducts = SessionData.item.ItemProducts; } return(model); } catch (Exception ex) { base.Log(ex); } finally { } return(null); }
public List <Category> GetCategories(Int32 customerId, CommonUnit.CategoryType type) { return(GetCategories(customerId, type, null)); }