Beispiel #1
0
        internal string ConvertcategorylisttoJson(List <CategorySimpleModel> categorylist, MegaMenuSettings megaMenuSettings)
        {
            List <DisplayorderModel> displayorderModelList = new List <DisplayorderModel>();

            foreach (CategorySimpleModel item in categorylist)
            {
                DisplayorderModel displayorderModel = new DisplayorderModel();

                displayorderModel.Id    = item.Id.ToString();
                displayorderModel.label = item.Name;

                displayorderModelList.Add(displayorderModel);
            }

            // displayorderModelList = addMegaMenuDropDownItems(displayorderModelList , megaMenuSettings);
            string topMenuCategoriesJson = function_convert_displayOrdermodel_to_json(displayorderModelList);

            return(topMenuCategoriesJson);
        }
Beispiel #2
0
        public List <DisplayorderModel> addMegaMenuDropDownItems(List <DisplayorderModel> displayorderModelList, MegaMenuSettings megaMenuSettings)
        {
            DisplayorderModel product = new DisplayorderModel();

            product.Id    = "product";
            product.label = "product megamenu";
            product.index = megaMenuSettings.productIndex;

            DisplayorderModel category = new DisplayorderModel();

            category.Id    = "category";
            category.label = "category megamenu";
            category.index = megaMenuSettings.categoryIndex;

            DisplayorderModel manufacturer = new DisplayorderModel();

            manufacturer.Id    = "manufacturer";
            manufacturer.label = "manufacturer megamenu";
            manufacturer.index = megaMenuSettings.manufacturerIndex;

            // insert smallest index first
            List <DisplayorderModel> tempdisplayorderModelList = new List <DisplayorderModel>();

            tempdisplayorderModelList.Add(product);
            tempdisplayorderModelList.Add(category);
            tempdisplayorderModelList.Add(manufacturer);

            var SortdisplayorderModelList = tempdisplayorderModelList.OrderBy(x => x.index).ToList();

            foreach (DisplayorderModel item in SortdisplayorderModelList)
            {
                displayorderModelList.Insert(item.index.Value, item);
            }

            return(displayorderModelList);
        }