public virtual async Task <ActionResult> GenerateNavbar() { var idMap = new Dictionary <int, int>(); foreach (var category in _postCategoriesService.GetAsEnumerable()) { var id = await _navBarService.AddAsync(new TblNavBarItems() { Index = category.DisplayOrder, InnerHtml = category.CategoryName, Name = category.CategoryName, Url = "/Categories/" + category.Slug }); var catLocals = await _localizedEntityService.GetLocalizedPropertiesAsync(category.Id, "TblPostCategories", "CategoryName"); foreach (var local in catLocals) { await _localizedEntityService.AddAsync(new TblLocalizedProperty() { LanguageId = local.LanguageId, EntityId = id, LocaleKeyGroup = "TblNavBarItems", LocaleKey = "InnerHtml", LocaleValue = local.LocaleValue }); } idMap.Add(category.Id, id); } foreach (var category in _postCategoriesService.GetAsEnumerable().Where(p => p.ParentCategoryId != null)) { var navbarItem = await _navBarService.FindByIdAsync(idMap[category.Id]); navbarItem.ParentItemId = idMap[category.ParentCategoryId.Value]; await _navBarService.UpdateAsync(navbarItem); } SuccessNotification(_localizationService.GetResource("OperationCompletedSuccessfully")); return(RedirectToAction("Index")); }