Ejemplo n.º 1
0
        protected void PrepareCategories(Dictionary <int, CategoryCached> categories)
        {
            foreach (var category in categories.Values)
            {
                category.Init1ParentAndSub(categories);
            }

            _rootCategory = categories[1];

            var categoriesList = _rootCategory.Init2AllSub();

            categoriesList.Insert(0, _rootCategory);

            foreach (var category in categoriesList)
            {
                category.Init3ISectionType(_allSectionTypes);
            }

            _rootCategory.Init4InitSectionsRoots();
            _rootCategory.Init5PreparePaths();

            foreach (var category in categoriesList)
            {
                category.Init6SetListsAndBlockEditable();
            }

            _allCategories = categoriesList.ToImmutableDictionary(x => x.NameNormalized);
        }
Ejemplo n.º 2
0
        protected void PrepareCategories(Dictionary <int, CategoryCached> categories)
        {
            foreach (var category in categories.Values)
            {
                category.Init1ParentAndSub(categories);
            }

            _rootCategory = categories.Values.FirstOrDefault(x => x.Name == Category.RootName);
            if (_rootCategory == null)
            {
                throw new Exception($"Can not find category '{Category.RootName}' in data base.");
            }


            var categoriesList = _rootCategory.Init2AllSub();

            categoriesList.Insert(0, _rootCategory);

            foreach (var category in categoriesList)
            {
                category.Init3ISectionType(_allSectionTypes);
            }

            _rootCategory.Init4InitSectionsRoots();

            foreach (var category in categoriesList)
            {
                category.Init5SetListsAndBlockEditable();
            }

            _allCategoriesByName =
                categoriesList.ToImmutableDictionary(x => x.NameNormalized, StringComparer.OrdinalIgnoreCase);

            _allCategoriesById = _allCategoriesByName.ToImmutableDictionary(x => x.Value.Id, x => x.Value);
        }