public MenuViewModel Build(CachedMenu cachedMenu)
        {
            IEnumerable<CachedMenuItem> cachedMenuItems = new CachedMenuItem[] { };

              if (!string.IsNullOrEmpty(cachedMenu.CachedMenuItems))
            cachedMenuItems = JsonConvert.DeserializeObject<IEnumerable<CachedMenuItem>>(cachedMenu.CachedMenuItems);

              return new MenuViewModel()
              {
            MenuItems = cachedMenuItems.OrderBy(cmi => cmi.Position).Select(
              cmi => new MenuItemViewModelBuilder(this.handler).Build(cmi)
            )
              };
        }
Ejemplo n.º 2
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;
        }