private static void SaveBanners(EditMenuItem editMenuItem, int menuItemID)
        {
            var curList = MenuItemBanners.GetByMenuItemID(menuItemID);

            foreach (var banner in editMenuItem.Banners)
            {
                if (!curList.Any(item => item.ID == banner.ID))
                {
                    var menuItemBanner = Mapper.Map <MenuItemBanner>(banner);

                    menuItemBanner.MenuItemID = menuItemID;
                    menuItemBanner.Key        = Guid.NewGuid();

                    MenuItemBanners.Insert(menuItemBanner);
                }
                else
                {
                    MenuItemBanners.UpdateMenuItemBannerType(banner.ID, banner.MenuItemBannerType);
                    curList.Remove(curList.Single(cls => cls.ID == banner.ID));
                }
            }

            foreach (var item in curList)
            {
                MenuItemBanners.Delete(item.ID);
            }
        }
        public ActionResult Edit(int?id)
        {
            EditMenuItem item;

            if (id.HasValue)
            {
                item = Mapper.Map <EditMenuItem>(MenuItems.GetByID(id.Value));

                item.Content = HttpUtility.HtmlDecode(item.Content);
                item.Banners = MenuItemBanners.GetByMenuItemID(item.ID);
            }
            else
            {
                item = new EditMenuItem();
            }

            return(View(item));
        }
Example #3
0
        public RedirectResult Index(string key)
        {
            string link = String.Empty;
            var    guid = Guid.Parse(key);

            bool found = Banners.AddClick(guid);

            if (found)
            {
                link = Banners.GetByGuid(guid).Link;
            }
            else
            {
                MenuItemBanners.AddClick(guid);
                link = MenuItemBanners.GetByGuid(guid).Link;
            }

            return(Redirect(link));
        }