private Menu GetMenu(MenuItem menuItem)
        {
            while (menuItem.MenuId == null)
            menuItem = this.Storage.GetRepository<IMenuItemRepository>().WithKey((int)menuItem.MenuItemId);

              return this.Storage.GetRepository<IMenuRepository>().WithKey((int)menuItem.MenuId);
        }
 public MenuItemViewModel Build(MenuItem menuItem)
 {
     return new MenuItemViewModel()
       {
     Name = this.GetObjectLocalizationValue(menuItem.NameId),
     Url = menuItem.Url,
     MenuItems = this.handler.Storage.GetRepository<IMenuItemRepository>().FilteredByMenuItemId(menuItem.Id).Select(
       mi => new MenuItemViewModelBuilder(this.handler).Build(mi)
     )
       };
 }
 public MenuItemViewModel Build(MenuItem menuItem)
 {
     return new MenuItemViewModel()
       {
     Id = menuItem.Id,
     Name = this.handler.Storage.GetRepository<ILocalizationRepository>().FilteredByDictionaryId(menuItem.NameId).First().Value,
     MenuItems = this.handler.Storage.GetRepository<IMenuItemRepository>().FilteredByMenuItemId(menuItem.Id).Select(
       mi => new MenuItemViewModelBuilder(this.handler).Build(mi)
     )
       };
 }
        public MenuItem Map(CreateOrEditViewModel createOrEdit)
        {
            MenuItem menuItem = new MenuItem();

              if (createOrEdit.Id != null)
            menuItem = this.handler.Storage.GetRepository<IMenuItemRepository>().WithKey((int)createOrEdit.Id);

              else
              {
            menuItem.MenuId = createOrEdit.MenuId;
            menuItem.MenuItemId = createOrEdit.MenuItemId;
              }

              menuItem.Url = createOrEdit.Url;
              menuItem.Position = createOrEdit.Position;
              return menuItem;
        }
        private CachedMenuItem CacheMenuItem(Culture culture, MenuItem menuItem)
        {
            List<CachedMenuItem> cachedChildMenuItems = new List<CachedMenuItem>();

              foreach (MenuItem childMenuItem in this.handler.Storage.GetRepository<IMenuItemRepository>().FilteredByMenuItemId(menuItem.Id))
            cachedChildMenuItems.Add(this.CacheMenuItem(culture, childMenuItem));

              CachedMenuItem cachedMenuItem = new CachedMenuItem();

              cachedMenuItem.MenuItemId = menuItem.Id;
              cachedMenuItem.Name = this.GetLocalizationValue(culture.Id, menuItem.NameId);
              cachedMenuItem.Url = menuItem.Url;
              cachedMenuItem.Position = menuItem.Position;

              if (cachedChildMenuItems.Count != 0)
            cachedMenuItem.CachedMenuItems = this.SerializeObject(cachedChildMenuItems);

              return cachedMenuItem;
        }
 private void CacheMenu(MenuItem menuItem)
 {
     new CacheManager(this).CacheMenu(this.GetMenu(menuItem));
 }