private void SetProductInfo(string prodId, string library)
        {
            int number;
            int productId = Int32.TryParse(prodId, out number) ? number : 0;

            List <CatalogItem> catalogItems;

            if (library == "catalog")
            {
                catalogItems = SharePointConnector.GetCatalog(productId, "ID", true);
            }
            else if (library == "suggs")
            {
                catalogItems = SharePointConnector.GetSuggestions(productId);
            }
            else
            {
                catalogItems = new List <CatalogItem>();
            }

            foreach (CatalogItem item in catalogItems)
            {
                litProductCategory.Text = string.Format(
                    @"<span><a href=""/Paginas/Club%20de%20Puntos/CategoriaClubPuntos.aspx?cat={0}"" title=""{1}""></a></span>" +
                    @"<h1 class=""left"">{2}</h1>",
                    item.CategoryId, item.Category, item.Category);

                litProductName.Text = string.Format(
                    @"<span></span><h1 class=""right"">{0}</h1>",
                    item.Title);

                litProductDetails.Text = string.Format(
                    @"<div><img src=""{0}"" /></div>" +
                    @"<div><span>" +
                    @"<h2>{1}</h2><h3>{2}</h3>" +
                    @"{3}" +
                    @"<ul class=""social"">" +
                    @"<li><a href=""http://www.facebook.com/sharer.php?u={4}"" class=""socialf"" title=""Compártenos en facebook"" target=""_blank""></a></li>" +
                    @"<li><a href=""https://twitter.com/share?url={4}"" class=""socialt"" title=""Compártenos en twitter"" target=""_blank""></a></li>" +
                    @"<li><a href=""https://plus.google.com/share?url={4}"" class=""socialg"" title=""Compártenos en google+"" target=""_blank""></a></li>" +
                    @"</ul>" +
                    @"</span></div>",
                    item.Image, FormatedPoints(item.Points) + " puntos", item.Category, item.Description,
                    System.Net.WebUtility.UrlEncode(Page.Request.Url.AbsoluteUri));
            }
        }
        private void PopulateRelated(string prodId, string library)
        {
            int number;
            int productId = Int32.TryParse(prodId, out number) ? number : 0;

            List <CatalogItem> tempCatalog;

            if (library == "catalog")
            {
                tempCatalog = SharePointConnector.GetCatalog(productId, "ID", true);
            }
            else if (library == "suggs")
            {
                tempCatalog = SharePointConnector.GetSuggestions(productId);
            }
            else
            {
                tempCatalog = new List <CatalogItem>();
            }

            int categoryId = tempCatalog.Count > 0 ? tempCatalog[0].CategoryId : 0;
            List <CatalogItem> catalogItems = SharePointConnector.GetCatalog(0, "ID", false);

            int count = 0;

            foreach (CatalogItem item in catalogItems)
            {
                if (item.CategoryId == categoryId && item.Id != productId)
                {
                    litRelatedProducts.Text += string.Format(
                        @"<li><a href=""{0}""><img src=""{1}""/></a><p><span>{2}</span><br/>{3}</p></li>",
                        item.Url(), item.Image, FormatedPoints(item.Points) + " puntos", item.Title);
                    count++;

                    if (count == 8)//eight is the limit
                    {
                        break;
                    }
                }
            }

            if (string.IsNullOrEmpty(litRelatedProducts.Text))
            {
                litRelatedProducts.Text = "No existen otros productos para esta categoría en este momento.";
            }
        }
        private void PopulateAllItems(string catId)
        {
            int number;
            int categoryId = Int32.TryParse(catId, out number) ? number : 0;
            List <CatalogItem> catalogItems = SharePointConnector.GetCatalog(0, "ID", true);

            foreach (CatalogItem item in catalogItems)
            {
                if (item.CategoryId == categoryId)
                {
                    litCategoryItems.Text += string.Format(
                        @"<li><a href=""{0}""><img src=""{1}""/></a><p><span>{2}</span><br/>{3}</p></li>",
                        item.Url(), item.Image, FormatedPoints(item.Points) + " puntos", item.Title);
                }
            }

            if (string.IsNullOrEmpty(litCategoryItems.Text))
            {
                litCategoryItems.Text = "No existen productos para esta categoría en este momento.";
            }
        }
        private void PopulateFilteredItems(string catId, string region, string brand, string orderBy, int[] range)
        {
            litCategoryItems.Text = "";

            int number;
            int categoryId = Int32.TryParse(catId, out number) ? number : 0;
            List <CatalogItem> catalogItems = new List <CatalogItem>();

            switch (orderBy)
            {
            case "PUNTOS_ASC":
                catalogItems = SharePointConnector.GetCatalog(0, "Puntos", true);
                break;

            case "PUNTOS_DES":
                catalogItems = SharePointConnector.GetCatalog(0, "Puntos", false);
                break;

            case "PRODUCTO":
                catalogItems = SharePointConnector.GetCatalog(0, "Title", true);
                break;
            }

            foreach (CatalogItem item in catalogItems)
            {
                if (item.CategoryId == categoryId && item.Region.Contains(region) && item.Brand == brand)
                {
                    if (item.Points >= range[0] && item.Points <= range[1])
                    {
                        litCategoryItems.Text += string.Format(
                            @"<li><a href=""{0}""><img src=""{1}""/></a><p><span>{2}</span><br/>{3}</p></li>",
                            item.Url(), item.Image, FormatedPoints(item.Points) + " puntos", item.Title);
                    }
                }
            }
        }