//
        // GET: /ContentBlocks/Top10Products/
        public ActionResult Index(ContentBlock b)
        {
            var profiler = MvcMiniProfiler.MiniProfiler.Current;
            using (profiler.Step("Block:Top10Products"))
            {
                SideMenuViewModel model = new SideMenuViewModel();

                System.DateTime s = new System.DateTime(1900, 1, 1);
                System.DateTime e = new System.DateTime(3000, 12, 31);
                List<Product> products;
                using (profiler.Step("Load top 10 products"))
                {
                    products = MTApp.ReportingTopSellersByDate(s, e, 10);
                }
                using (profiler.Step("Prep Products"))
                {
                    foreach (Product p in products)
                    {
                        SideMenuItem item = new SideMenuItem();
                        item.Title = p.ProductName;
                        item.Name = p.ProductName;
                        item.Url = UrlRewriter.BuildUrlForProduct(p, MTApp.CurrentRequestContext.RoutingContext, string.Empty);
                        item.Name += " - " + p.SitePrice.ToString("C");
                        model.Items.Add(item);
                    }
                }

                model.Title = "Top Sellers";
                return View(model);
            }
        }
        //
        // GET: /ContentBlocks/ImageRotator/
        public ActionResult Index(ContentBlock block)
        {
            ImageRotatorViewModel model = new ImageRotatorViewModel();

            if (block != null)
            {
                var imageList = block.Lists.FindList("Images");
                foreach (var listItem in imageList)
                {
                    ImageRotatorImageViewModel img = new ImageRotatorImageViewModel();
                    img.ImageUrl = ResolveUrl(listItem.Setting1);
                    img.Url = listItem.Setting2;
                    if (img.Url.StartsWith("~"))
                    {
                        img.Url = Url.Content(img.Url);
                    }
                    img.NewWindow = (listItem.Setting3 == "1");
                    img.Caption = listItem.Setting4;
                    model.Images.Add(img);
                }
                string cleanId = MerchantTribe.Web.Text.ForceAlphaNumericOnly(block.Bvin);
                model.CssId = "rotator" + cleanId;
                model.CssClass = block.BaseSettings.GetSettingOrEmpty("cssclass");

                model.Height = block.BaseSettings.GetIntegerSetting("Height");
                model.Width = block.BaseSettings.GetIntegerSetting("Width");

                if (block.BaseSettings.GetBoolSetting("ShowInOrder") == false)
                {
                    RandomizeList(model.Images);
                }
            }

            return View(model);
        }
        //
        // GET: /ContentBlocks/CategoryRotator/
        public ActionResult Index(ContentBlock block)
        {
            var profiler = MvcMiniProfiler.MiniProfiler.Current;
            using (profiler.Step("Block:CategoryRotator"))
            {
                SingleCategoryViewModel model = new SingleCategoryViewModel();

                bool showInOrder = false;
                if (block != null)
                {
                    showInOrder = block.BaseSettings.GetBoolSetting("ShowInOrder");

                    int nextIndex;
                    if (Session[block.Bvin + "NextImageIndex"] != null)
                    {
                        nextIndex = (int)Session[block.Bvin + "NextImageIndex"];
                    }
                    else
                    {
                        nextIndex = 0;
                    }

                    List<ContentBlockSettingListItem> settings = block.Lists.FindList("Categories");

                    if (settings.Count != 0)
                    {
                        if (settings.Count > nextIndex)
                        {
                            LoadCategory(model, settings[nextIndex].Setting1);
                        }
                        else if (nextIndex >= settings.Count)
                        {
                            if (showInOrder)
                            {
                                nextIndex = 0;
                            }
                            else
                            {
                                nextIndex = MerchantTribe.Web.RandomNumbers.RandomInteger(settings.Count - 1, 0);
                            }
                            LoadCategory(model, settings[nextIndex].Setting1);
                        }

                        if (showInOrder)
                        {
                            nextIndex += 1;
                        }
                        else
                        {
                            nextIndex = MerchantTribe.Web.RandomNumbers.RandomInteger(settings.Count - 1, 0);
                        }
                        Session[block.Bvin + "NextImageIndex"] = nextIndex;
                    }

                }

                return View(model);
            }
        }
        //
        // GET: /ContentBlocks/LastProductsViewed/
        public ActionResult Index(ContentBlock block)
        {
            ProductListViewModel model = new ProductListViewModel();
            model.Title = SiteTerms.GetTerm(SiteTermIds.RecentlyViewedItems);
            model.Items = LoadItems();

            return View(model);
        }
 //
 // GET: /ContentBlocks/FeaturedProducts/
 public ActionResult Index(ContentBlock block)
 {
     var profiler = MvcMiniProfiler.MiniProfiler.Current;
     using (profiler.Step("Block:FeaturedProducts"))
     {
         FeaturedProductsViewModel model = new FeaturedProductsViewModel();
         model.Items = PrepProducts(MTApp.CatalogServices.Products.FindFeatured(1, 100));
         return View(model);
     }
 }
        //
        // GET: /ContentBlocks/ProductGrid/
        public ActionResult Index(ContentBlock block)
        {
            var profiler = MvcMiniProfiler.MiniProfiler.Current;
            using (profiler.Step("Block:ProductGrid"))
            {

                List<SingleProductViewModel> model = LoadProductGrid(block);
                return View(model);
            }
        }
 public static IContentBlockRenderController GetRenderer(ContentBlock block)
 {
     string noSpacesName = block.ControlName.Replace(" ", "");
     noSpacesName = noSpacesName.ToLowerInvariant();
     if (Controllers.ContainsKey(noSpacesName))
     {
         return Controllers[noSpacesName];
     }
     return new NullRenderer();
 }
        private List<SingleProductViewModel> LoadProductGrid(ContentBlock b, MerchantTribeApplication app)
        {
            List<SingleProductViewModel> result = new List<SingleProductViewModel>();

            List<ContentBlockSettingListItem> myProducts = b.Lists.FindList("ProductGrid");
            if (myProducts != null)
            {
                int column = 1;

                if (b != null)
                {
                    int maxColumns = b.BaseSettings.GetIntegerSetting("GridColumns");
                    if (maxColumns < 1) maxColumns = 3;


                    // Pull all products in a single db call instead of individual calls
                    List<string> allProductBvins = myProducts.Select(y => y.Setting1).ToList();
                    List<Product> allProducts = app.CatalogServices.Products.FindMany(allProductBvins);

                    foreach (ContentBlockSettingListItem sett in myProducts)
                    {
                        string bvin = sett.Setting1;
                        Product p = allProducts.Where(y => y.Bvin == bvin).FirstOrDefault(); // app.CatalogServices.Products.Find(bvin);
                        if (p != null)
                        {
                            bool isLastInRow = false;
                            bool isFirstInRow = false;
                            if ((column == 1))
                            {
                                isFirstInRow = true;
                            }

                            if ((column == maxColumns))
                            {
                                column = 1;
                                isLastInRow = true;
                            }
                            else
                            {
                                column += 1;
                            }

                            SingleProductViewModel vm = new SingleProductViewModel(p, app);
                            vm.IsFirstItem = isFirstInRow;
                            vm.IsLastItem = isLastInRow;

                            result.Add(vm);
                        }
                    }
                }
            }

            return result;
        }
        protected override void OnInit(System.EventArgs e)
        {
            base.OnInit(e);

            if (Request.QueryString["id"] != null)
            {
                this.BlockIDField.Value = Request.QueryString["id"];
            }
            b = MTApp.ContentServices.Columns.FindBlock(this.BlockIDField.Value);
            LoadEditor();
        }
        public bool MoveBlockToColumn(string blockBvin, string columnId)
        {
            ContentBlock b = this.blockRepository.Find(blockBvin);

            if (b != null)
            {
                b.ColumnId = columnId;
                return(blockRepository.Update(b));
            }
            return(false);
        }
Example #11
0
        private void InstallColumn(string xmlData)
        {
            if (xmlData == string.Empty)
            {
                return;
            }

            XmlDocument xdoc = new XmlDocument();

            xdoc.LoadXml(xmlData);

            // Find Column
            XmlNode bvinNode = xdoc.SelectSingleNode("/ContentColumn/Bvin");

            if (bvinNode == null)
            {
                return;
            }
            string columnBvin = bvinNode.InnerText;

            ContentColumn col = MTApp.ContentServices.Columns.Find(columnBvin);

            if (col == null)
            {
                return;
            }
            if (col.SystemColumn == false)
            {
                return;
            }

            // remove existing blocks
            col.Blocks.Clear();
            MTApp.ContentServices.Columns.Update(col);

            // add blocks from xml
            XmlNodeList blockNodes;

            blockNodes = xdoc.SelectNodes("/ContentColumn/Blocks/ContentBlock");

            if (blockNodes != null)
            {
                for (int i = 0; i <= blockNodes.Count - 1; i++)
                {
                    ContentBlock b = new ContentBlock();
                    b.FromXmlString(blockNodes[i].OuterXml);
                    b.Bvin = string.Empty;
                    col.Blocks.Add(b);
                }
            }
            MTApp.ContentServices.Columns.Update(col);
        }
        //
        // GET: /ContentBlocks/TopWeeklySellers/
        public ActionResult Index(ContentBlock b)
        {
            SideMenuViewModel model = new SideMenuViewModel();
            model.Title = "Top Weekly Sellers";

            DateTime _StartDate = DateTime.Now;
            DateTime _EndDate = DateTime.Now;
            System.DateTime c = DateTime.Now;
            CalculateDates(c, _StartDate, _EndDate);
            model.Items = LoadProducts(_StartDate, _EndDate);

            return View(model);
        }
        private void LoadMenu(CategoryMenuViewModel model, ContentBlock b)
        {
            model.CurrentId = LocateCurrentCategory();
            if (b != null)
            {
                // Load Title
                string title = b.BaseSettings.GetSettingOrEmpty("Title");
                if (title.Trim().Length > 0)
                {
                    model.Title = "<h4>" + title + "</h4>";
                }


                model.ShowProductCounts = b.BaseSettings.GetBoolSetting("ShowProductCount");
                model.ShowCategoryCounts = b.BaseSettings.GetBoolSetting("ShowCategoryCount");
                model.sb.Append("<ul>");

                if (b.BaseSettings.GetBoolSetting("HomeLink") == true)
                {
                    AddHomeLink(model);
                }

                string mode = b.BaseSettings.GetSettingOrEmpty("CategoryMenuMode");
                switch (mode)
                {
                    case "0":
                        // Root Categories Only
                        LoadRoots(model);
                        break;
                    case "1":
                        // All Categories
                        LoadAllCategories(model, b.BaseSettings.GetIntegerSetting("MaximumDepth"));
                        break;
                    case "2":
                        // Peers, Children and Parents
                        LoadPeersAndChildren(model);
                        break;
                    case "3":
                        // Show root and expanded children
                        LoadRootPlusExpandedChildren(model);
                        break;
                    default:
                        // All Categories
                        LoadRoots(model);
                        break;
                }

                model.sb.Append("</ul>");
            }
        }
        protected void btnNew_Click(object sender, System.Web.UI.ImageClickEventArgs e)
        {

            ContentColumn col = MyPage.MTApp.ContentServices.Columns.Find(this.ColumnId);
            if (col != null)
            {
                ContentBlock b = new ContentBlock();
                b.ControlName = this.lstBlocks.SelectedValue;                
                b.ColumnId = this.ColumnId;
                col.Blocks.Add(b);
                MyPage.MTApp.ContentServices.Columns.Update(col);
            }
            LoadColumn();
        }
Example #15
0
        //
        // GET: /ContentBlocks/Html/
        public ActionResult Index(ContentBlock block)
        {
            string result = string.Empty;
            if (block != null)
            {
                result = block.BaseSettings.GetSettingOrEmpty("HtmlData");
            }

            result = TagReplacer.ReplaceContentTags(result,
                                                    MTApp,
                                                    "",
                                                    Request.IsSecureConnection);
            return Content(result);
        }
        private List<SingleProductViewModel> LoadProductGrid(ContentBlock b)
        {
            List<SingleProductViewModel> result = new List<SingleProductViewModel>();

            List<ContentBlockSettingListItem> myProducts = b.Lists.FindList("ProductGrid");
            if (myProducts != null)
            {
                int column = 1;

                if (b != null)
                {
                    int maxColumns = b.BaseSettings.GetIntegerSetting("GridColumns");
                    if (maxColumns < 1) maxColumns = 3;

                    foreach (ContentBlockSettingListItem sett in myProducts)
                    {
                        string bvin = sett.Setting1;
                        Product p = MTApp.CatalogServices.Products.Find(bvin);
                        if (p != null)
                        {
                            bool isLastInRow = false;
                            bool isFirstInRow = false;
                            if ((column == 1))
                            {
                                isFirstInRow = true;
                            }

                            if ((column == maxColumns))
                            {
                                column = 1;
                                isLastInRow = true;
                            }
                            else
                            {
                                column += 1;
                            }

                            SingleProductViewModel vm = new SingleProductViewModel(p, MTApp);
                            vm.IsFirstItem = isFirstInRow;
                            vm.IsLastItem = isLastInRow;

                            result.Add(vm);
                        }
                    }
                }
            }

            return result;
        }
Example #17
0
 private void BindCategoryGridView(ContentBlock b)
 {
     List<ContentBlockSettingListItem> settings = b.Lists.FindList("Categories");
     Collection<Category> categories = new Collection<Category>();
     foreach (ContentBlockSettingListItem item in settings)
     {
         Category category = MyPage.MTApp.CatalogServices.Categories.Find(item.Setting1);
         if (category != null && category.Bvin != string.Empty)
         {
             categories.Add(category);
         }
     }
     CategoriesGridView.DataSource = categories;
     CategoriesGridView.DataBind();
 }
        //
        // GET: /ContentBlocks/TopWeeklySellers/
        public ActionResult Index(ContentBlock b)
        {
            var profiler = MvcMiniProfiler.MiniProfiler.Current;
            using (profiler.Step("Block:TopWeeklySellers"))
            {
                SideMenuViewModel model = new SideMenuViewModel();
                model.Title = "Top Weekly Sellers";

                DateTime _StartDate = DateTime.Now;
                DateTime _EndDate = DateTime.Now;
                System.DateTime c = DateTime.Now;
                CalculateDates(c, _StartDate, _EndDate);
                model.Items = LoadProducts(_StartDate, _EndDate);

                return View(model);
            }
        }
        private Product LoadProduct(ContentBlock b)
        {
            List<ContentBlockSettingListItem> myProducts = b.Lists.FindList("Products");
            if (myProducts != null)
            {
                if (myProducts.Count > 0)
                {
                    int displayIndex = GetProductIndex(myProducts.Count - 1);

                    ContentBlockSettingListItem data = myProducts[displayIndex];
                    string bvin = data.Setting1;
                    Product p = MTApp.CatalogServices.Products.Find(bvin);
                    return p;
                }
            }
            return null;
        }
Example #20
0
 public ContentBlock Clone()
 {
     ContentBlock clone = new ContentBlock();
     clone.StoreId = this.StoreId;
     clone.LastUpdated = DateTime.UtcNow;
     clone.ColumnId = this.ColumnId;
     clone.SortOrder = this.SortOrder;
     clone.ControlName = this.ControlName;
     foreach (var q in BaseSettings)
     {
         clone.BaseSettings.Add(q.Key, q.Value);
     }
     foreach (var y in Lists.Items)
     {
         clone.Lists.AddItem(y.Clone());
     }
     return clone;
 }
        //
        // GET: /ContentBlocks/BannerAd/
        public ActionResult Index(ContentBlock block)
        {
            BannerAdViewModel model = new BannerAdViewModel();

            if (block != null)
            {
                model.ImageUrl = block.BaseSettings.GetSettingOrEmpty("imageurl");
                model.AltText = block.BaseSettings.GetSettingOrEmpty("alttext");
                model.CssId = block.BaseSettings.GetSettingOrEmpty("cssid");
                model.CssClass = block.BaseSettings.GetSettingOrEmpty("cssclass");
                model.LinkUrl = block.BaseSettings.GetSettingOrEmpty("linkurl");
                model.ImageUrl = TagReplacer.ReplaceContentTags(model.ImageUrl,
                                                                MTApp,
                                                                "",
                                                                Request.IsSecureConnection);
            }

            return View(model);
        }
Example #22
0
        public ContentBlock Clone()
        {
            ContentBlock clone = new ContentBlock();

            clone.StoreId     = this.StoreId;
            clone.LastUpdated = DateTime.UtcNow;
            clone.ColumnId    = this.ColumnId;
            clone.SortOrder   = this.SortOrder;
            clone.ControlName = this.ControlName;
            foreach (var q in BaseSettings)
            {
                clone.BaseSettings.Add(q.Key, q.Value);
            }
            foreach (var y in Lists.Items)
            {
                clone.Lists.AddItem(y.Clone());
            }
            return(clone);
        }
        //
        // GET: /ContentBlocks/Html/
        public ActionResult Index(ContentBlock block)
        {
            var profiler = MvcMiniProfiler.MiniProfiler.Current;
            using (profiler.Step("Block:Html"))
            {

                string result = string.Empty;
                if (block != null)
                {
                    result = block.BaseSettings.GetSettingOrEmpty("HtmlData");
                }

                result = TagReplacer.ReplaceContentTags(result,
                                                        MTApp,
                                                        "",
                                                        Request.IsSecureConnection);
                return Content(result);
            }
        }
        public bool CopyBlockToColumn(string blockBvin, string columnId)
        {
            ContentBlock b = this.blockRepository.Find(blockBvin);

            if (b != null)
            {
                ContentBlock clone = b.Clone();
                clone.ColumnId = columnId;
                clone.Bvin     = string.Empty;
                ContentColumn newColumn = Find(columnId);
                if (newColumn != null)
                {
                    newColumn.Blocks.Add(clone);
                    return(Update(newColumn));
                }
                return(false);
            }
            return(false);
        }
        //
        // GET: /ContentBlocks/SideMenu/
        public ActionResult Index(ContentBlock block)
        {
            SideMenuViewModel model = new SideMenuViewModel();

            if (block != null)
            {
                model.Title = block.BaseSettings.GetSettingOrEmpty("Title");

                List<ContentBlockSettingListItem> links = block.Lists.FindList("Links");
                if (links != null)
                {
                    foreach (ContentBlockSettingListItem l in links)
                    {
                        model.Items.Add(AddSingleLink(l));
                    }
                }
            }

            return View(model);
        }
        //
        // GET: /ContentBlocks/RssFeedViewer/
        public ActionResult Index(ContentBlock block)
        {
            RssFeedViewModel model = new RssFeedViewModel();
            model.Channel = new RSSChannel(new MerchantTribe.Commerce.EventLog());

            if (block != null)
            {
                string feedUrl = block.BaseSettings.GetSettingOrEmpty("FeedUrl");
                model.Channel.LoadFromFeed(feedUrl);
                model.ShowTitle = block.BaseSettings.GetBoolSetting("ShowTitle");
                model.ShowDescription = block.BaseSettings.GetBoolSetting("ShowDescription");
                int max = block.BaseSettings.GetIntegerSetting("MaxItems");
                if (max <= 0)
                {
                    max = 5;
                }
                model.MaxItems = max;
            }

            return View(model);
        }
 //
 // GET: /ContentBlocks/ProductGrid/
 public ActionResult Index(ContentBlock block)
 {
     List<SingleProductViewModel> model = LoadProductGrid(block);
     return View(model);
 }
        public string Render(MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, MerchantTribe.Commerce.Content.ContentBlock block)
        {
            this.MTApp   = app;
            this.ViewBag = viewBag;

            CategoryMenuViewModel model = new CategoryMenuViewModel();

            LoadMenu(model, block);
            return(Render(model));
        }
        public string Render(MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, MerchantTribe.Commerce.Content.ContentBlock block)
        {
            List <SingleProductViewModel> model = LoadProductGrid(block, app);

            return(RenderModel(model, app));
        }
Example #30
0
 private void LoadItems(ContentBlock b)
 {
     this.GridView1.DataSource = b.Lists.FindList(SettingListName);
     this.GridView1.DataKeyNames = new string[] { "Id" };
     this.GridView1.DataBind();
 }
Example #31
0
        public string Render(MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, MerchantTribe.Commerce.Content.ContentBlock block)
        {
            SideMenuViewModel model = new SideMenuViewModel();

            System.DateTime s = new System.DateTime(1900, 1, 1);
            System.DateTime e = new System.DateTime(3000, 12, 31);
            List <Product>  products;

            products = app.ReportingTopSellersByDate(s, e, 10);
            foreach (Product p in products)
            {
                SideMenuItem item = new SideMenuItem();
                item.Title = p.ProductName;
                item.Name  = p.ProductName;
                item.Url   = UrlRewriter.BuildUrlForProduct(p, app.CurrentRequestContext.RoutingContext, string.Empty);
                item.Name += " - " + p.SitePrice.ToString("C");
                model.Items.Add(item);
            }

            model.Title = "Top Sellers";

            return(RenderModel(model));
        }
        public string Render(MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, MerchantTribe.Commerce.Content.ContentBlock block)
        {
            SideMenuViewModel model = new SideMenuViewModel();

            model.Title = "Top Weekly Sellers";

            DateTime _StartDate = DateTime.Now;
            DateTime _EndDate   = DateTime.Now;

            System.DateTime c = DateTime.Now;
            CalculateDates(c, _StartDate, _EndDate);
            model.Items = LoadProducts(app, _StartDate, _EndDate);

            model.Title = "Top Sellers";

            return(RenderModel(model));
        }
 //
 // GET: /ContentBlocks/CategoryMenu/
 public ActionResult Index(ContentBlock block)
 {
     CategoryMenuViewModel model = new CategoryMenuViewModel();
     LoadMenu(model, block);
     return View(model);
 }
 //
 // GET: /ContentBlocks/FeaturedProducts/
 public ActionResult Index(ContentBlock block)
 {
     FeaturedProductsViewModel model = new FeaturedProductsViewModel();
     model.Items = PrepProducts(MTApp.CatalogServices.Products.FindFeatured(1, 100));
     return View(model);
 }
Example #35
0
 private void LoadItems(ContentBlock b)
 {
     this.GridView1.DataSource = b.Lists.FindList("Products");
     this.GridView1.DataBind();
 }
Example #36
0
        private void InstallColumn(string xmlData)
        {            
            if (xmlData == string.Empty) return;

            XmlDocument xdoc = new XmlDocument();
            xdoc.LoadXml(xmlData);
            
            // Find Column
            XmlNode bvinNode = xdoc.SelectSingleNode("/ContentColumn/Bvin");
            if (bvinNode == null) return;
            string columnBvin = bvinNode.InnerText;

            ContentColumn col = MTApp.ContentServices.Columns.Find(columnBvin);
            if (col == null) return;
            if (col.SystemColumn == false) return;

            // remove existing blocks
            col.Blocks.Clear();
            MTApp.ContentServices.Columns.Update(col);

            // add blocks from xml
            XmlNodeList blockNodes;
            blockNodes = xdoc.SelectNodes("/ContentColumn/Blocks/ContentBlock");

            if (blockNodes != null)
            {
                for (int i = 0; i <= blockNodes.Count - 1; i++)
                {

                    ContentBlock b = new ContentBlock();
                    b.FromXmlString(blockNodes[i].OuterXml);                    
                    b.Bvin = string.Empty;
                    col.Blocks.Add(b);
                }
            }
            MTApp.ContentServices.Columns.Update(col);

        }
Example #37
0
        public string Render(MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, MerchantTribe.Commerce.Content.ContentBlock block)
        {
            Product p = null;
            List <ContentBlockSettingListItem> myProducts = block.Lists.FindList("Products");

            if (myProducts != null)
            {
                if (myProducts.Count > 0)
                {
                    int displayIndex = GetProductIndex(myProducts.Count - 1);

                    ContentBlockSettingListItem data = myProducts[displayIndex];
                    string bvin = data.Setting1;
                    p = app.CatalogServices.Products.Find(bvin);
                }
            }

            if (p != null)
            {
                SingleProductViewModel model = new SingleProductViewModel(p, app);
                return(RenderModel(model, app));
            }
            return(string.Empty);
        }
Example #38
0
        public string Render(MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, MerchantTribe.Commerce.Content.ContentBlock block)
        {
            SideMenuViewModel model = new SideMenuViewModel();

            if (block != null)
            {
                model.Title = block.BaseSettings.GetSettingOrEmpty("Title");

                List <ContentBlockSettingListItem> links = block.Lists.FindList("Links");
                if (links != null)
                {
                    foreach (ContentBlockSettingListItem l in links)
                    {
                        model.Items.Add(AddSingleLink(l));
                    }
                }
            }

            return(RenderModel(model));
        }
 public static string RenderBlock(ContentBlock block, MerchantTribeApplication app, dynamic viewBag)
 {
     var renderer = GetRenderer(block);
     return renderer.Render(app, viewBag, block);
 }
 public bool UpdateBlock(ContentBlock item)
 {
     return(this.blockRepository.Update(item));
 }
        public string Render(MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, MerchantTribe.Commerce.Content.ContentBlock block)
        {
            ProductListViewModel model = new ProductListViewModel();

            model.Title = SiteTerms.GetTerm(SiteTermIds.RecentlyViewedItems);
            model.Items = LoadItems(app);

            return(RenderModel(model, app));
        }
 //
 // GET: /ContentBlocks/ProductRotator/
 public ActionResult Index(ContentBlock block)
 {
     Product p = LoadProduct(block);
     return View(p);
 }
        public string Render(MerchantTribe.Commerce.MerchantTribeApplication app, dynamic viewBag, MerchantTribe.Commerce.Content.ContentBlock block)
        {
            SingleCategoryViewModel model = new SingleCategoryViewModel();

            bool showInOrder = false;

            if (block != null)
            {
                showInOrder = block.BaseSettings.GetBoolSetting("ShowInOrder");

                List <ContentBlockSettingListItem> settings = block.Lists.FindList("Categories");

                int nextIndex = GetProductIndex(settings.Count - 1);

                if (settings.Count != 0)
                {
                    if (settings.Count > nextIndex)
                    {
                        LoadCategory(model, settings[nextIndex].Setting1, app);
                    }
                    else if (nextIndex >= settings.Count)
                    {
                        if (showInOrder)
                        {
                            nextIndex = 0;
                        }
                        else
                        {
                            nextIndex = MerchantTribe.Web.RandomNumbers.RandomInteger(settings.Count - 1, 0);
                        }
                        LoadCategory(model, settings[nextIndex].Setting1, app);
                    }

                    if (showInOrder)
                    {
                        nextIndex += 1;
                    }
                    else
                    {
                        nextIndex = MerchantTribe.Web.RandomNumbers.RandomInteger(settings.Count - 1, 0);
                    }
                }
            }

            return(RenderModel(model));
        }