private void MenuLeft() { MenuDoc mn = new MenuDoc(); DataTable dtb = mn.Menu(); DataTable dtb2; DataRow drRow; for (int i = 0; i < dtb.Rows.Count; i++) { AjaxControlToolkit.AccordionPane accp = new AjaxControlToolkit.AccordionPane(); drRow = dtb.Rows[i]; Label lblHeader = new Label(); lblHeader.ID = "lblHead" + i.ToString(); lblHeader.Text = "<a href='#'>" + drRow["CateName"].ToString() + "</a>"; dtb2 = mn.GetCategory(@"Select CateID, CateName From TB_Category Where MenuLevel=1 And ParentID=" + drRow["CateID"].ToString()); Label lblContent = new Label(); lblContent.ID = "lblContent" + i.ToString(); lblContent.Text = ""; accp.ID = "accp" + i.ToString(); foreach (DataRow dr in dtb2.Rows) { lblContent.Text += "<a href='ChuyenMuc.aspx?CateID=" + dr["CateID"] + "'>"; lblContent.Text += @"<img src='Images/blue_bubble.png' border='0' />"; lblContent.Text += @" " + @" " + dr["CateName"].ToString() + "</a><br>"; } accp.HeaderContainer.Controls.Add(lblHeader); accp.ContentContainer.Controls.Add(lblContent); Accordion1.Panes.Add(accp); } }
public List <ModifierGroupDto> ModifierList(MenuDoc menu, Product product, ProductDto productDto) { var modifierGroupsList = new List <ModifierGroupDto>(); var productModifierGroups = menu.ModifierGroups.Where(mg => product.ModifierGroups.Contains(mg.Key)).OrderBy(o => o.Value.DisplayOrder); foreach (var item in productModifierGroups) { var mgDto = ModifierGrouptoModifierGroupDto(item.Key, item.Value, menu, false); mgDto.Product = productDto; modifierGroupsList.Add(mgDto); } return(modifierGroupsList); }
private List <CategoryDto> ListCategories(MenuDoc menu) { var categorieDtos = new List <CategoryDto>(); foreach (var category in menu.Categories) { var categoryDto = CategoryToCategoryDto(category, menu.Products); var productDtos = new List <ProductDto>(); var productIds = category.SubMenuItems.Select(sub => sub.ProductID).ToList(); var products = menu.Products.Where(p => productIds.Contains(int.Parse(p.Key))); foreach (var product in products) { var pp = product.Value; var pDto = new ProductDto { ID = int.Parse(product.Key), DisplayOrder = pp.DisplayOrder, FullDescription = pp.FullDescription, Name = pp.Name, PhotoUrl = pp.PhotoUrl, ProductCode = pp.ProductCode, ShortDescription = pp.ShortDescription, Status = pp.Status ?? 0, TaxRate = pp.TaxRate, ProductCategoryIDs = pp.ProductCategoryNames, ProductTagIDs = pp.ProductTagIDs, }; pDto.ModifierGroups = ModifierList(menu, product.Value, pDto); var categoryProduct = category.SubMenuItems.FirstOrDefault(sItem => sItem.ProductID == pDto.ID); pDto.Price = categoryProduct.Price.Value; pDto.Name = categoryProduct.Name; productDtos.Add(pDto); } categoryDto.Products.AddRange(productDtos); if (category.SubMenuItems.Any()) { categorieDtos.Add(categoryDto); } } return(categorieDtos); }
private ModifierGroupDto ModifierGrouptoModifierGroupDto(string key, ModifierGroup mg, MenuDoc menu, bool cancel) { if (mg.MaximumSelection == 0) { mg.MaximumSelection = null; } if (mg.MaximumSelection.HasValue && mg.MinimumSelection.HasValue && mg.MaximumSelection.Value < mg.MinimumSelection.Value) { mg.MaximumSelection = mg.MinimumSelection; } var mgDto = new ModifierGroupDto { ID = key, DisplayOrder = mg.DisplayOrder, IsAutoSel = mg.IsAutoSel, IsForceSel = mg.IsForceSel, IsSingleSel = mg.IsSingleSel, IsCollapsed = mg.IsCollapsed.HasValue ? mg.IsCollapsed.Value : false, Name = mg.Name, IsPromptSel = mg.IsPromptSel.HasValue ? mg.IsPromptSel.Value : false, MaximumSelection = mg.MaximumSelection, MinimumSelection = mg.MinimumSelection, IncludeQuantity = mg.IncludeQuantity, }; foreach (var mod in mg.Modifiers.OrderBy(o => o.DisplayOrder)) { var mDto = new ModifierDto { Code = mod.Code, DisplayName = mod.DisplayName, DisplayOrder = mod.DisplayOrder, ID = mod.ID, MaxQty = mod.MaxQty, MinQty = mod.MinQty, Name = mod.Name, Status = mod.Status, OldState = mod.Status, PhotoUrl = mod.PhotoURL, Price = mod.Price, TaxRate = mod.TaxRate, LinkedProductID = mod.LinkedProductId, ModifierGroupId = int.Parse(mgDto.ID), ModifierGroup = mgDto, }; if (!string.IsNullOrEmpty(mod.LinkedProductId)) { var linkedProduct = menu.Products.Where(p => p.Key == mod.LinkedProductId).FirstOrDefault(); if (linkedProduct.Key != null) { mDto.Status = linkedProduct.Value.Status ?? 0; mDto.OldState = linkedProduct.Value.Status == 3 ? 0 : linkedProduct.Value.Status; if (!cancel) { var linkedModifierGroups = menu.ModifierGroups.Where(group => linkedProduct.Value.ModifierGroups.Contains(group.Key)).OrderBy(o => o.Value.DisplayOrder); foreach (var linkedGroup in linkedModifierGroups) { var currentMdg = ModifierGrouptoModifierGroupDto(linkedGroup.Key, linkedGroup.Value, menu, true); mDto.SubModifiers.Add(currentMdg); currentMdg.ParentModifier = mDto; } } } } mgDto.ModifiersList.Add(mDto); } return(mgDto); }