public static List <MenuDTO> getMenu() { if (HttpContext.Current.Application["MENU"] != null) { return(HttpContext.Current.Application["MENU"] as List <MenuDTO>); } DataTable dt = GenericService.getVewImageNewMasterDT(); IEnumerable <DataRow> query = from dr in dt.AsEnumerable() where dr.Field <String>("CategoryID") != null && dr.Field <String>("CategoryID") != String.Empty orderby dr.Field <String>("SKUCategory") select dr; try { query = query.Distinct(new DistictComparer("CategoryID")); dt = query.CopyToDataTable <DataRow>(); } catch (InvalidOperationException e) { Logger.Error("Exception occur HomeService.getMenu()", e); dt = new DataTable(); } List <MenuDTO> dtos = new List <MenuDTO>(); for (int a = 0; a < dt.Rows.Count; a++) { MenuDTO menu = new MenuDTO(); menu.Heading = dt.Rows[a]["SKUCategory"] + ""; menu.Url = ConfigUtil.hostURL() + "" + StringUtil.urlEncode(dt.Rows[a]["SKUCategory"] + "").Trim(); menu.Id = dt.Rows[a]["SKUCategory"] + "-section"; DataTable dt1 = getSubMenuDT(dt.Rows[a]["CategoryID"] + ""); for (int i = 0; i < dt1.Rows.Count; i++) { MenuDTO subMenu = new MenuDTO(); subMenu.Heading = dt1.Rows[i]["SKUCategoryType"] + ""; subMenu.Url = ConfigUtil.hostURL() + "" + StringUtil.urlEncode(dt1.Rows[i]["CategoryTypeUrlName"] + "").Trim(); subMenu.Id = dt1.Rows[i]["CategoryTypeID"] + ""; DataTable dt2 = getMenuItemDT(dt1.Rows[i]["CategoryTypeID"] + ""); for (int j = 0; j < dt2.Rows.Count; j++) { MenuDTO menuItem = new MenuDTO(); menuItem.Heading = dt2.Rows[j]["SKUProductType"] + ""; string str = StringUtil.urlEncode(dt2.Rows[j]["SKUProductType"] + ""); menuItem.Url = subMenu.Url.Trim() + "/" + str.Trim(); menuItem.Id = dt2.Rows[j]["ProductTypeID"] + ""; subMenu.addContent(menuItem); } menu.addContent(subMenu); } dtos.Add(menu); } HttpContext.Current.Application["MENU"] = dtos; return(dtos); }
public static List <MenuDTO> getMenuDT(String menuType) { if (HttpContext.Current.Application[menuType] != null) { return(HttpContext.Current.Application[menuType] as List <MenuDTO>); } DataTable dt = GenericService.getVewImageNewMasterDT(); IEnumerable <DataRow> query = from dr in dt.AsEnumerable() where dr.Field <String>("SKUCategory") == menuType && dr.Field <String>("CategoryTypeID") != null && dr.Field <String>("CategoryTypeID") != String.Empty orderby dr.Field <String>("SKUCategory") select dr; try { query = query.Distinct(new DistictComparer("CategoryTypeID")); dt = query.CopyToDataTable <DataRow>(); } catch (InvalidOperationException e) { Logger.Error("Exception occur HomeService.getMenuDT()", e); dt = new DataTable(); } List <MenuDTO> dtos = new List <MenuDTO>(); for (int i = 0; i < dt.Rows.Count; i++) { MenuDTO dto = new MenuDTO(); dto.Heading = dt.Rows[i]["SKUCategoryType"] + ""; dto.Url = ConfigUtil.hostURL() + "" + dt.Rows[i]["CategoryTypeUrlName"] + ""; DataTable dt1 = CategoriesService.getDistictProductByCatType(dt.Rows[i]["CategoryTypeID"] + ""); for (int j = 0; j < dt1.Rows.Count; j++) { MenuDTO subDto = new MenuDTO(); subDto.Heading = dt1.Rows[j]["SKUProductType"] + ""; string str = StringUtil.urlEncode(dt1.Rows[j]["SKUProductType"] + ""); subDto.Url = dto.Url + "/" + str; dto.addContent(subDto); } dtos.Add(dto); HttpContext.Current.Application[menuType] = dtos; } return(dtos); }
public static List <MenuDTO> getBrandMenuDT() { if (HttpContext.Current.Application[Constant.Application.BRAND_MENU] != null) { return(HttpContext.Current.Application[Constant.Application.BRAND_MENU] as List <MenuDTO>); } DataTable dt = GenericService.getVewImageNewMasterDT(); IEnumerable <DataRow> query = from dr in dt.AsEnumerable() select dr; try { query = query.Distinct(new DistictComparer("SKUCategory")); dt = query.CopyToDataTable <DataRow>(); } catch (InvalidOperationException e) { Logger.Error("Exception occur HomeService.getMenuDT()", e); dt = new DataTable(); } List <MenuDTO> dtos = new List <MenuDTO>(); for (int i = 0; i < dt.Rows.Count; i++) { MenuDTO dto = new MenuDTO(); dto.Heading = dt.Rows[i]["SKUCategory"] + ""; dto.Url = ConfigUtil.hostURL() + "" + dt.Rows[i]["SKUCategory"] + ""; DataTable dt1 = CategoriesService.getDistictProductByCat(dt.Rows[i]["SKUCategory"] + ""); for (int j = 0; j < dt1.Rows.Count; j++) { MenuDTO subDto = new MenuDTO(); subDto.Heading = dt1.Rows[j]["SKUBrand"] + ""; subDto.Url = ConfigUtil.hostURL() + "Shop-By-Brand/" + dt1.Rows[j]["SKUCategoryType"] + "?Brand=" + dt1.Rows[j]["SKUBrand"]; dto.addContent(subDto); } dtos.Add(dto); if (dtos != null) { HttpContext.Current.Application[Constant.Application.BRAND_MENU] = dtos; } } return(dtos); }