public MenuViewModel Build(Menu menu)
 {
     return new MenuViewModel()
       {
     MenuItems = this.handler.Storage.GetRepository<IMenuItemRepository>().FilteredByMenuId(menu.Id).Select(
       mi => new MenuItemViewModelBuilder(this.handler).Build(mi)
     )
       };
 }
        public Menu Map(CreateOrEditViewModel createOrEdit)
        {
            Menu menu = new Menu();

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

              menu.Code = createOrEdit.Code;
              return menu;
        }
 public MenuViewModel Build(Menu menu)
 {
     return new MenuViewModel()
       {
     Id = menu.Id,
     Name = this.handler.Storage.GetRepository<ILocalizationRepository>().FilteredByDictionaryId(menu.NameId).First().Value,
     MenuItems = this.handler.Storage.GetRepository<IMenuItemRepository>().FilteredByMenuId(menu.Id).Select(
       mi => new MenuItemViewModelBuilder(this.handler).Build(mi)
     )
       };
 }
Esempio n. 4
0
        private CachedMenu CacheMenu(Culture culture, Menu menu)
        {
            List<CachedMenuItem> cachedMenuItems = new List<CachedMenuItem>();

              foreach (MenuItem menuItem in this.handler.Storage.GetRepository<IMenuItemRepository>().FilteredByMenuId(menu.Id))
            cachedMenuItems.Add(this.CacheMenuItem(culture, menuItem));

              CachedMenu cachedForm = new CachedMenu();

              cachedForm.MenuId = menu.Id;
              cachedForm.CultureId = culture.Id;
              cachedForm.Code = menu.Code;

              if (cachedMenuItems.Count != 0)
            cachedForm.CachedMenuItems = this.SerializeObject(cachedMenuItems);

              return cachedForm;
        }
Esempio n. 5
0
        public void CacheMenu(Menu menu)
        {
            foreach (Culture culture in this.handler.Storage.GetRepository<ICultureRepository>().All())
              {
            CachedMenu cachedMenu = this.handler.Storage.GetRepository<ICachedMenuRepository>().WithKey(culture.Id, menu.Id);

            if (cachedMenu == null)
              this.handler.Storage.GetRepository<ICachedMenuRepository>().Create(this.CacheMenu(culture, menu));

            else
            {
              CachedMenu temp = this.CacheMenu(culture, menu);

              cachedMenu.Code = temp.Code;
              cachedMenu.CachedMenuItems = temp.CachedMenuItems;
              this.handler.Storage.GetRepository<ICachedMenuRepository>().Edit(cachedMenu);
            }
              }

              this.handler.Storage.Save();
        }