public void YouMayAlsoLikeSettingUpdate(string SettingValues, string SettingKeys, AspxCommonInfo aspxCommonObj)
 {
     try
     {
         AspxYouMayAlsoLikeController objYouMayLike = new AspxYouMayAlsoLikeController();
         objYouMayLike.YouMayAlsoLikeSettingUpdate(SettingValues, SettingKeys, aspxCommonObj);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }  
 public List<YouMayAlsoLikeInfo> GetYouMayAlsoLikeItems(string itemSKU, AspxCommonInfo aspxCommonObj, int count)
 {
     try
     {
         AspxYouMayAlsoLikeController objYouMayLike = new AspxYouMayAlsoLikeController();
         List<YouMayAlsoLikeInfo> lstYouMayLike = objYouMayLike.GetYouMayAlsoLikeItems(itemSKU, aspxCommonObj, count);
         return lstYouMayLike;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
    public YouMayAlsoLikeSettingInfo GetYouMayAlsoLikeSetting(AspxCommonInfo aspxCommonObj)
    {
        try
        {
            AspxYouMayAlsoLikeController objYouMayLike = new AspxYouMayAlsoLikeController();
            YouMayAlsoLikeSettingInfo lstYouMayAlsoLike = objYouMayLike.GetYouMayAlsoLikeSetting(aspxCommonObj);
            return lstYouMayAlsoLike;

        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
 public void GetYouMayAlsoLikeSetting()
 {
     AspxCommonInfo aspxCommonObj = new AspxCommonInfo();
     aspxCommonObj.StoreID = StoreID;
     aspxCommonObj.PortalID = PortalID;
     aspxCommonObj.CultureName = CultureName;
     JavaScriptSerializer json_serializer = new JavaScriptSerializer();
     AspxYouMayAlsoLikeController objYouMayLike = new AspxYouMayAlsoLikeController();
     YouMayAlsoLikeSettingInfo lstYouMayAlsoLikeSetting = objYouMayLike.GetYouMayAlsoLikeSetting(aspxCommonObj);
     if (lstYouMayAlsoLikeSetting != null)
     {
         object obj = new
         {
             EnableYouMayAlsoLike = lstYouMayAlsoLikeSetting.IsEnableYouMayAlsoLike,
             NoOfYouMayAlsoLikeItems = lstYouMayAlsoLikeSetting.YouMayAlsoLikeCount,
             NoOfYouMayAlsoLikeInARow = lstYouMayAlsoLikeSetting.YouMayAlsoLikeInARow,
             YouMayAlsoLikeModulePath = YouMayAlsoLikeModulePath
         };
         Settings = json_serializer.Serialize(obj);
     }        
 }
    public void GetItemRelatedUpSellAndCrossSellList(string itemsku)
    {
        AspxCommonInfo aspxCommonObj = new AspxCommonInfo();
        aspxCommonObj.StoreID = StoreID;
        aspxCommonObj.PortalID = PortalID;
        aspxCommonObj.UserName = UserName;
        aspxCommonObj.CultureName = CultureName;
        aspxCommonObj.CustomerID = CustomerID;
        aspxCommonObj.SessionCode = SessionCode;
        string modulePath = this.AppRelativeTemplateSourceDirectory;
        string aspxTemplateFolderPath = ResolveUrl("~/") + "Templates/" + TemplateName;
        string aspxRootPath = ResolveUrl("~/");
        hst = AppLocalized.getLocale(modulePath);
        string pageExtension = SageFrameSettingKeys.PageExtension;
        AspxYouMayAlsoLikeController objYouMayLike = new AspxYouMayAlsoLikeController();
        List<YouMayAlsoLikeInfo> lstRelatedItem = objYouMayLike.GetYouMayAlsoLikeItems(itemsku, aspxCommonObj, NoOfYouMayAlsoLikeItems);
        StringBuilder realatedItemCartContent = new StringBuilder();
         if (lstRelatedItem != null && lstRelatedItem.Count > 0)
        {
            realatedItemCartContent.Append("<h2 class=\"sfLocale\">You May Also Like</h2>");   
            foreach (YouMayAlsoLikeInfo item in lstRelatedItem)
            {
                string imagePath = "Modules/AspxCommerce/AspxItemsManagement/uploads/" + item.BaseImage;
                string altImagePath = "Modules/AspxCommerce/AspxItemsManagement/uploads/" + item.Name;
                if (item.BaseImage == "")
                {
                    imagePath = NoImageYouMayAlsoLikePath;
                }
                else
                {
                    //Resize Image Dynamically
                    InterceptImageController.ImageBuilder(item.BaseImage, ImageType.Medium, ImageCategoryType.Item, aspxCommonObj);
                }
                if (item.AlternateText == "")
                {
                    item.AlternateText = item.Name;
                }
                string itemPrice = Convert.ToDecimal(item.Price).ToString("N2");
                string itemPriceValue = item.Price;
                string itemPriceRate = Convert.ToDecimal(item.Price).ToString("N2"); 
                StringBuilder dataContent = new StringBuilder();
                dataContent.Append("data-class=\"addtoCart\" data-ItemTypeID=\"" + item.ItemTypeID + "\" data-ItemID=\"" + item.ItemID + "\"data-type=\"button\" data-addtocart=\"");
                dataContent.Append("addtocart");
                dataContent.Append(item.ItemID);
                dataContent.Append("\" data-title=\"");
                dataContent.Append(item.Name);
                dataContent.Append("\" data-onclick=\"AspxCommerce.RootFunction.AddToCartFromJS(");
                dataContent.Append(item.ItemID);
                dataContent.Append(",");
                dataContent.Append(itemPriceValue);
                dataContent.Append(",'");
                dataContent.Append(item.SKU);
                dataContent.Append("',");
                dataContent.Append(1);
                dataContent.Append(",'");
                dataContent.Append(item.IsCostVariantItem);
                dataContent.Append("',this);\"");           
                if ((lstRelatedItem.IndexOf(item) + 1) % NoOfYouMayAlsoLikeInARow == 0)
                {
                    realatedItemCartContent.Append("<div class=\"cssClassProductsBox cssClassNoMargin\">");
                }
                else
                {
                    realatedItemCartContent.Append("<div class=\"cssClassProductsBox\">");
                }
                var hrefItem = aspxRedirectPath + "item/" + fixedEncodeURIComponent(item.SKU) + pageExtension;
                realatedItemCartContent.Append("<div id=\"productImageWrapID_");
                realatedItemCartContent.Append(item.ItemID);
                realatedItemCartContent.Append("\" class=\"cssClassProductsBoxInfo\" costvariantItem=");
                realatedItemCartContent.Append(item.IsCostVariantItem);
                realatedItemCartContent.Append("  itemid=\"");
                realatedItemCartContent.Append(item.ItemID);
                realatedItemCartContent.Append("\">");
                realatedItemCartContent.Append("<h3>");
                realatedItemCartContent.Append(item.SKU);
                realatedItemCartContent.Append("</h3><div class=\"divQuickLookonHover\"><div class=\"divitemImage cssClassProductPicture\"><a href=\"");
                realatedItemCartContent.Append(hrefItem);
                realatedItemCartContent.Append("\" ><img id=\"img_");
                realatedItemCartContent.Append(item.ItemID);
                realatedItemCartContent.Append("\"  alt=\"");
                realatedItemCartContent.Append(item.AlternateText);
                realatedItemCartContent.Append("\"  title=\"");
                realatedItemCartContent.Append(item.AlternateText);
                realatedItemCartContent.Append("\"");
                realatedItemCartContent.Append("src=\"");
                realatedItemCartContent.Append(aspxRootPath);
                realatedItemCartContent.Append(imagePath.Replace("uploads", "uploads/Medium"));
                realatedItemCartContent.Append("\" orignalPath=\"");
                realatedItemCartContent.Append(imagePath.Replace("uploads", "uploads/Medium"));
                realatedItemCartContent.Append("\" altImagePath=\"");
                realatedItemCartContent.Append(altImagePath.Replace("uploads", "uploads/Medium"));
                realatedItemCartContent.Append("\"/></a></div>");
                realatedItemCartContent.Append("<div class='cssLatestItemInfo'>");
                realatedItemCartContent.Append("<h2><a href=\"");
                realatedItemCartContent.Append(hrefItem);
                realatedItemCartContent.Append("\" title=\"" + item.Name + "\">");
                string name = string.Empty;
                if (item.Name.Length > 50)
                {
                    name = item.Name.Substring(0, 50);
                    int index = 0;
                    index = name.LastIndexOf(' ');
                    name = name.Substring(0, index);
                    name = name + "...";
                }
                else
                {
                    name = item.Name;
                }
                realatedItemCartContent.Append(name);
                realatedItemCartContent.Append("</a></h2>");
                if (item.HidePrice != true)
                {
                    if (item.ListPrice != null && item.ListPrice!="")
                    {

                                               if (item.ItemTypeID == 5)
                        {
                            realatedItemCartContent.Append("<div class=\"cssClassProductPriceBox\"><div class=\"cssClassProductPrice\">");
                            realatedItemCartContent.Append("<p class=\"cssClassProductRealPrice \">");
                            realatedItemCartContent.Append(getLocale("Starting At "));
                            realatedItemCartContent.Append("<span class=\"cssClassFormatCurrency\">");
                            realatedItemCartContent.Append(itemPriceRate);
                            realatedItemCartContent.Append("</span></p></div></div>");

                        }
                        else
                        {
                            string strAmount = Math.Round(Convert.ToDecimal(item.ListPrice), 2).ToString("N2");
                            realatedItemCartContent.Append("<div class=\"cssClassProductPriceBox\"><div class=\"cssClassProductPrice\">");
                            realatedItemCartContent.Append("<p class=\"cssClassProductOffPrice\">");
                            realatedItemCartContent.Append("<span class=\"cssClassFormatCurrency\">");
                            realatedItemCartContent.Append(strAmount);
                            realatedItemCartContent.Append("</span></p><p class=\"cssClassProductRealPrice \">");
                            realatedItemCartContent.Append("<span class=\"cssClassFormatCurrency\">");
                            realatedItemCartContent.Append(itemPriceRate);
                            realatedItemCartContent.Append("</span></p></div></div>");
                        }
                    }
                    else
                    {//Added for group type products
                        if (item.ItemTypeID == 5)
                        {
                            realatedItemCartContent.Append("<div class=\"cssClassProductPriceBox\"><div class=\"cssClassProductPrice\">");
                            realatedItemCartContent.Append("<p class=\"cssClassProductRealPrice \">");
                            realatedItemCartContent.Append(getLocale("Starting At "));
                            realatedItemCartContent.Append("<span class=\"cssClassFormatCurrency\">");
                            realatedItemCartContent.Append(itemPriceRate);
                            realatedItemCartContent.Append("</span></p></div></div>");
                        }
                        else
                        {
                            realatedItemCartContent.Append("<div class=\"cssClassProductPriceBox\"><div class=\"cssClassProductPrice\">");
                            realatedItemCartContent.Append("<p class=\"cssClassProductRealPrice \">");
                            realatedItemCartContent.Append("<span class=\"cssClassFormatCurrency\">");
                            realatedItemCartContent.Append(itemPriceRate);
                            realatedItemCartContent.Append("</span></p></div></div>");
                        }
                    }
                }
                else
                {
                    realatedItemCartContent.Append("<div class=\"cssClassProductPriceBox\"></div>");
                }
                realatedItemCartContent.Append("<div class=\"cssClassProductDetail\"><p><a href=\"");
                realatedItemCartContent.Append(aspxRedirectPath);
                realatedItemCartContent.Append("item/");
                realatedItemCartContent.Append(item.SKU);
                realatedItemCartContent.Append(pageExtension);
                realatedItemCartContent.Append("\">");
                realatedItemCartContent.Append(getLocale("Details"));
                realatedItemCartContent.Append("</a></p></div>");

                realatedItemCartContent.Append("<div class=\"sfQuickLook\" style=\"display:none\">");
                realatedItemCartContent.Append("<img itemId=\"");
                realatedItemCartContent.Append(item.ItemID);
                realatedItemCartContent.Append("\" sku=\"");
                realatedItemCartContent.Append(item.SKU);
                realatedItemCartContent.Append("\" src=\"");
                realatedItemCartContent.Append(aspxTemplateFolderPath);
                realatedItemCartContent.Append("/images/QV_Button.png\" alt=\"\" rel=\"popuprel\" />");
                realatedItemCartContent.Append("</div>");
                string itemSKU = item.SKU;
                string itemName = item.Name;
                if (AllowAddToCart.ToLower() == "true")
                {
                    if (AllowOutStockPurchase.ToLower() == "false")
                    {
                        if (item.IsOutOfStock == true)
                        {

                            realatedItemCartContent.Append("<div class=\"cssClassAddtoCard\"><div " + dataContent + " class=\"sfButtonwrapper cssClassOutOfStock\">");
                            realatedItemCartContent.Append("<button type=\"button\"><span>");
                            realatedItemCartContent.Append(getLocale("Out Of Stock"));
                            realatedItemCartContent.Append("</span></button></div></div>");
                        }
                        else
                        {
                            realatedItemCartContent.Append("<div class=\"cssClassAddtoCard\"><div " + dataContent + "class=\"sfButtonwrapper\">");
                            realatedItemCartContent.Append("<label class='i-cart cssClassCartLabel cssClassGreenBtn'><button type=\"button\" class=\"addtoCart\"");
                            realatedItemCartContent.Append("data-addtocart=\"");
                            realatedItemCartContent.Append("addtocart");
                            realatedItemCartContent.Append(item.ItemID);
                            realatedItemCartContent.Append("\" title=\"");
                            realatedItemCartContent.Append(itemName);
                            realatedItemCartContent.Append("\" onclick=\"AspxCommerce.RootFunction.AddToCartFromJS(");
                            realatedItemCartContent.Append(item.ItemID);
                            realatedItemCartContent.Append(",");
                            realatedItemCartContent.Append(itemPriceValue);
                            realatedItemCartContent.Append(",'");
                            realatedItemCartContent.Append(itemSKU);
                            realatedItemCartContent.Append("',");
                            realatedItemCartContent.Append(1);
                            realatedItemCartContent.Append(",'");
                            realatedItemCartContent.Append(item.IsCostVariantItem);
                            realatedItemCartContent.Append("',this);\">");
                            realatedItemCartContent.Append(getLocale("Cart +"));
                            realatedItemCartContent.Append("</button></label></div></div>");
                        }
                    }
                    else
                    {
                        realatedItemCartContent.Append("<div class=\"cssClassAddtoCard\"><div " + dataContent + " class=\"sfButtonwrapper\">");
                        realatedItemCartContent.Append("<label class='i-cart cssClassCartLabel cssClassGreenBtn'><button type=\"button\" class=\"addtoCart\"");
                        realatedItemCartContent.Append("data-addtocart=\"");
                        realatedItemCartContent.Append("addtocart");
                        realatedItemCartContent.Append(item.ItemID);
                        realatedItemCartContent.Append("\" title=\"");
                        realatedItemCartContent.Append(itemName);
                        realatedItemCartContent.Append("\" onclick=\"AspxCommerce.RootFunction.AddToCartFromJS(");
                        realatedItemCartContent.Append(item.ItemID);
                        realatedItemCartContent.Append(",");
                        realatedItemCartContent.Append(itemPriceValue);
                        realatedItemCartContent.Append(",'");
                        realatedItemCartContent.Append(itemSKU);
                        realatedItemCartContent.Append("',");
                        realatedItemCartContent.Append(1);
                        realatedItemCartContent.Append(",'");
                        realatedItemCartContent.Append(item.IsCostVariantItem);
                        realatedItemCartContent.Append("',this);\">");
                        realatedItemCartContent.Append(getLocale("Cart +"));
                        realatedItemCartContent.Append("</button></label></div></div>");

                    }
                    realatedItemCartContent.Append("</div></div>");
                }
                realatedItemCartContent.Append("</div>");
                realatedItemCartContent.Append("</div>");
            }
        }       
        ltrRelatedItemInCart.Text = realatedItemCartContent.ToString();
    }      
    public void GetYouMayAlsoLikeSetting()
    {
        AspxCommonInfo aspxCommonObj = new AspxCommonInfo();
        aspxCommonObj.StoreID = StoreID;
        aspxCommonObj.PortalID = PortalID;
        aspxCommonObj.CultureName = CultureName;
        AspxYouMayAlsoLikeController objYouMayLike = new AspxYouMayAlsoLikeController();
        YouMayAlsoLikeSettingInfo lstRelatedItemSetting = objYouMayLike.GetYouMayAlsoLikeSetting(aspxCommonObj);


        if (lstRelatedItemSetting != null)
        {
            EnableYouMayAlsoLike = lstRelatedItemSetting.IsEnableYouMayAlsoLike;
            NoOfYouMayAlsoLikeItems = lstRelatedItemSetting.YouMayAlsoLikeCount;
            NoOfYouMayAlsoLikeInARow = lstRelatedItemSetting.YouMayAlsoLikeInARow;

        }
    }