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()
       {
     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.ObjectId = createOrEdit.ObjectId;
              menuItem.Url = createOrEdit.Url;
              menuItem.Position = createOrEdit.Position;
              return menuItem;
        }
        public MenuItemViewModel Build(MenuItem menuItem)
        {
            string url = string.Empty;

              if (menuItem.ObjectId == null)
            url = menuItem.Url;

              url = this.handler.Storage.GetRepository<IObjectRepository>().WithKey((int)menuItem.ObjectId).Url;

              return new MenuItemViewModel()
              {
            Name = this.GetObjectLocalizationValue(menuItem.NameId),
            Url = url,
            MenuItems = this.handler.Storage.GetRepository<IMenuItemRepository>().FilteredByMenuItemId(menuItem.Id).Select(
              mi => new MenuItemViewModelBuilder(this.handler).Build(mi)
            )
              };
        }
 private void CacheMenu(MenuItem menuItem)
 {
     new CacheManager(this).CacheMenu(this.GetMenu(menuItem));
 }