public List<AttributeFormInfo> GetItemFormAttributesValuesByItemID(int itemID, int attributeSetID, int itemTypeID, int storeID, int portalID, string userName, string culture)
 {
     ItemsManagementSqlProvider obj = new ItemsManagementSqlProvider();
     List<AttributeFormInfo> frmItemAttributes = obj.GetItemAttributesValuesByItemID(itemID, attributeSetID, itemTypeID, storeID, portalID, userName, culture);
     return frmItemAttributes;
 }
 public void UpdateItemIsActiveByItemID(int itemId, int storeId, int portalId, string userName, bool isActive)
 {
     try
     {
         ItemsManagementSqlProvider obj = new ItemsManagementSqlProvider();
         obj.UpdateItemIsActive(itemId, storeId, portalId, userName, isActive);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public void DeleteItemByItemID(string itemId, int storeId, int portalId, string userName)
 {
     try
     {
         ItemsManagementSqlProvider obj = new ItemsManagementSqlProvider();
         obj.DeleteSingleItem(itemId, storeId, portalId, userName);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public List<AttributeFormInfo> GetItemFormAttributesByitemSKUOnly(string itemSKU, int storeID, int portalID, string userName, string culture)
 {
     ItemsManagementSqlProvider obj = new ItemsManagementSqlProvider();
     List<AttributeFormInfo> frmItemFieldList = obj.GetItemFormAttributesByItemSKUOnly(itemSKU, storeID, portalID, userName, culture);
     return frmItemFieldList;
 }
 public List<CostVariantInfo> GetCostVariantsOptionsList(int itemId, int storeId, int portalId, string cultureName)
 {
     try
     {
         ItemsManagementSqlProvider obj = new ItemsManagementSqlProvider();
         return obj.GetAllCostVariantOptions(itemId, storeId, portalId, cultureName);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 6
0
        public int SaveUpdateItemAndAttributes(int itemID, int itemTypeID, int attributeSetID, int storeID, int portalID, string userName, string culture, int taxClassID, string categoriesIDs, string relatedItemsIDs, string upSellItemsIDs, string crossSellItemsIDs, string downloadItemsValue, AspxNameValue[] formVars)
        {
            bool isModified = false;
            bool updateFlag = false;
            if (itemID > 0)
            {
                isModified = true;
                updateFlag = true;
            }
            StoreSettingConfig ssc = new StoreSettingConfig();
            int itemLargeThumbNailSize = Convert.ToInt32(ssc.GetStoreSettingsByKey(StoreSetting.ItemLargeThumbnailImageSize, storeID,
                                                                                                portalID, culture));
            int itemMediumThumbNailSize = Convert.ToInt32(ssc.GetStoreSettingsByKey(StoreSetting.ItemMediumThumbnailImageSize,
                                                                                                 storeID, portalID, culture));
            int itemSmallThumbNailSize = Convert.ToInt32(ssc.GetStoreSettingsByKey(StoreSetting.ItemSmallThumbnailImageSize, storeID,
                                                                                                portalID, culture));
            int _attributeID = 0;
            int _inputTypeID = 0;
            int _ValidationTypeID = 8;
            int _attributeSetGroupID = 0;
            bool _isIncludeInPriceRule = false;
            bool _isIncludeInPromotions = false;
            int _displayOrder = 0;

            string sku = "";
            string activeFrom = "";
            string activeTo = "";
            string hidePrice = "";
            string isHideInRSS = "";
            string isHideToAnonymous = "";

            bool toInsertIntoDB = true;
            bool isFormValid = true;
            string imageVar = string.Empty;
            int imageCounterFirst = 0;

            ItemsManagementSqlProvider obj = new ItemsManagementSqlProvider();

            for (int i = 0; i < formVars.Length; i++)
            {
                string attribValue = formVars[i].value;
                //string jsonResult = formVars[i].name.Replace('%', '_');
                string jsonResult = formVars[i].name.Replace('-', ' ');
                string[] jsonVar = jsonResult.Split('_');
                FormValidation formValidation = new FormValidation();

                if (jsonVar.Length > 1)
                {
                    _attributeID = Int32.Parse(jsonVar[0]);
                    _inputTypeID = Int32.Parse(jsonVar[1]);
                    _ValidationTypeID = Int32.Parse(jsonVar[2]);
                    _attributeSetGroupID = Int32.Parse(jsonVar[4]);
                    _isIncludeInPriceRule = bool.Parse(jsonVar[5]);
                    _isIncludeInPromotions = bool.Parse(jsonVar[6]);
                    _displayOrder = Int32.Parse(jsonVar[7]);

                    //Save To Database 1. [aspx_Items] 2. Others 
                    if (_attributeID == 4)
                    {
                        sku = formVars[i].value;
                    }
                    else if (_attributeID == 22)
                    {
                        activeFrom = formVars[i].value;
                    }
                    else if (_attributeID == 23)
                    {
                        activeTo = formVars[i].value;
                    }
                    else if (_attributeID == 26)
                    {
                        hidePrice = formVars[i].value;
                    }
                    else if (_attributeID == 27)
                    {
                        isHideInRSS = formVars[i].value;
                    }
                    else if (_attributeID == 28)
                    {
                        isHideToAnonymous = formVars[i].value;
                    }


                    if (itemID == 0 && updateFlag == false)
                    {
                        itemID = obj.AddItem(itemID, itemTypeID, attributeSetID, taxClassID, storeID, portalID, userName, culture, true, isModified,
                            sku, activeFrom, activeTo, hidePrice, isHideInRSS, isHideToAnonymous, categoriesIDs, relatedItemsIDs, upSellItemsIDs, crossSellItemsIDs, downloadItemsValue, updateFlag);
                    }
                    else if (itemID > 0 && i == formVars.Length - 1)
                    {
                        itemID = obj.AddItem(itemID, itemTypeID, attributeSetID, taxClassID, storeID, portalID, userName, culture, true, isModified,
                            sku, activeFrom, activeTo, hidePrice, isHideInRSS, isHideToAnonymous, categoriesIDs, relatedItemsIDs, upSellItemsIDs, crossSellItemsIDs, downloadItemsValue, updateFlag);
                    }

                    if (itemID > 0)
                    {
                        if (_inputTypeID == 1)
                        {
                            if (_ValidationTypeID == 3)
                            {
                                if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                                {
                                    attribValue = formVars[i].value;
                                }
                                else
                                {
                                    isFormValid = false;
                                    break;
                                }
                            }
                            else if (_ValidationTypeID == 5)
                            {
                                if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                                {
                                    attribValue = formVars[i].value;
                                }
                                else
                                {
                                    isFormValid = false;
                                    break;
                                }
                            }
                            else
                            {
                                if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                                {
                                    attribValue = formVars[i].value;
                                }
                                else
                                {
                                    isFormValid = false;
                                    break;
                                }
                            }
                        }
                        else if (_inputTypeID == 2)
                        {
                            if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                            {
                                attribValue = formVars[i].value;
                            }
                            else
                            {
                                isFormValid = false;
                                break;
                            }
                        }
                        else if (_inputTypeID == 3)
                        {
                            if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                            {
                                if (!string.IsNullOrEmpty(formVars[i].value))
                                {
                                    attribValue = formVars[i].value;
                                }
                            }
                            else
                            {
                                isFormValid = false;
                                break;
                            }
                        }
                        else if (_inputTypeID == 4)
                        {
                            if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                            {
                                if (!string.IsNullOrEmpty(formVars[i].value))
                                {
                                    attribValue = formVars[i].value;
                                }
                            }
                            else
                            {
                                isFormValid = false;
                                break;
                            }
                        }
                        else if (_inputTypeID == 5 || _inputTypeID == 6 || _inputTypeID == 9 || _inputTypeID == 10 ||
                                 _inputTypeID == 11 || _inputTypeID == 12)
                        {
                            if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                            {
                                attribValue = formVars[i].value;
                            }
                            else
                            {
                                isFormValid = false;
                                break;
                            }
                        }
                        else if (_inputTypeID == 7)
                        {
                            if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                            {
                                attribValue = formVars[i].value;
                            }
                            else
                            {
                                isFormValid = false;
                                break;
                            }
                        }

                        else if (_inputTypeID == 8)
                        {
                            if (imageCounterFirst % 2 == 0)
                            {
                                toInsertIntoDB = false;
                                if (!string.IsNullOrEmpty(formVars[i].value) && formVars[i].value.ToLower() != "undefined")
                                {
                                    if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                                    {
                                        imageVar = attribValue;
                                    }
                                    else
                                    {
                                        isFormValid = false;
                                        break;
                                    }
                                }
                                else
                                {
                                    imageVar = "";
                                }
                            }
                            else
                            {
                                toInsertIntoDB = true;

                                if (attribValue != imageVar)
                                {
                                    //_imageVar = _imageVar.Replace("../", "");
                                    imageVar = imageVar.Replace("/", "\\");
                                    //attribValue = attribValue.Replace("../", "");
                                    attribValue = attribValue.Replace("/", "\\");

                                    string tempFolder = @"Upload\temp";
                                    FileHelperController fileObj = new FileHelperController();
                                    attribValue = fileObj.MoveFileToModuleFolder(tempFolder, attribValue, imageVar, itemLargeThumbNailSize, itemMediumThumbNailSize,  itemSmallThumbNailSize, @"Modules\AspxCommerce\AspxItemsManagement\uploads\", itemID, "item_");
                                }
                            }
                            imageCounterFirst++;
                        }
                    }
                    if (isFormValid && toInsertIntoDB)
                    {
                        obj.SaveUpdateItemAttributes(itemID, attributeSetID, storeID, portalID, userName, culture, true, isModified, attribValue,
                            _attributeID, _inputTypeID, _ValidationTypeID, _attributeSetGroupID, _isIncludeInPriceRule, _isIncludeInPromotions,
                            _displayOrder);
                    }
                }
            }
            return itemID;
        }
 public List<ItemsInfo> GetItemsList(int offset, int limit, string sku, string name, string itemType, string attributesetName, string visibility, System.Nullable<bool> isActive, int storeId, int portalId, string userName, string cultureName)
 {
     try
     {
         ItemsManagementSqlProvider obj = new ItemsManagementSqlProvider();
         return obj.GetAllItems(offset, limit, sku, name, itemType, attributesetName, visibility, isActive, storeId, portalId, userName, cultureName);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public void DeleteImageContents(Int32 itemID)
 {
     try
     {
         ItemsManagementSqlProvider obj = new ItemsManagementSqlProvider();
         obj.DeleteItemImageByItemID(itemID);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public ItemBasicDetailsInfo GetItemBasicInfoByitemSKU(string itemSKU, int storeID, int portalID, string userName, string culture)
 {
     ItemsManagementSqlProvider obj = new ItemsManagementSqlProvider();
     ItemBasicDetailsInfo frmItemAttributes = obj.GetItemBasicInfo(itemSKU, storeID, portalID, userName, culture);
     return frmItemAttributes;
 }
 public List<AttributeFormInfo> GetItemDetailsByitemSKU(string itemSKU, int attributeSetID, int itemTypeID, int storeID, int portalID, string userName, string culture)
 {
     ItemsManagementSqlProvider obj = new ItemsManagementSqlProvider();
     List<AttributeFormInfo> frmItemAttributes = obj.GetItemDetailsInfoByItemSKU(itemSKU, attributeSetID, itemTypeID, storeID, portalID, userName, culture);
     return frmItemAttributes;
 }
 public List<LatestItemsInfo> GetLatestItemsList(int storeId, int portalId, string userName, string cultureName, int count)
 {
     try
     {
         ItemsManagementSqlProvider obj = new ItemsManagementSqlProvider();
         return obj.GetLatestItemsByCount(storeId, portalId, userName, cultureName, count);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public List<TaxRulesInfo> GetAllTaxRules(int storeID, int portalID, bool isActive)
 {
     ItemsManagementSqlProvider obj = new ItemsManagementSqlProvider();
     List<TaxRulesInfo> lstTaxManageRule = obj.GetAllTaxRules(storeID, portalID, isActive);
     return lstTaxManageRule;
 }
        public int SaveUpdateItemAndAttributes(ItemsInfo.ItemSaveBasicInfo itemObj, AspxCommonInfo aspxCommonObj)
        {
            bool   isModified = false;
            bool   updateFlag = false;
            int    storeId    = aspxCommonObj.StoreID;
            int    portalId   = aspxCommonObj.PortalID;
            string culture    = aspxCommonObj.CultureName;
            string userName   = aspxCommonObj.UserName;

            if (itemObj.ItemId > 0)
            {
                isModified = true;
                updateFlag = true;
            }
            StoreSettingConfig ssc     = new StoreSettingConfig();
            int itemLargeThumbNailSize =
                Convert.ToInt32(ssc.GetStoreSettingsByKey(StoreSetting.ItemLargeThumbnailImageSize, storeId, portalId, culture));
            int itemMediumThumbNailSize =
                Convert.ToInt32(ssc.GetStoreSettingsByKey(StoreSetting.ItemMediumThumbnailImageSize, storeId, portalId, culture));
            int itemSmallThumbNailSize =
                Convert.ToInt32(ssc.GetStoreSettingsByKey(StoreSetting.ItemSmallThumbnailImageSize, storeId, portalId, culture));
            int  _attributeID           = 0;
            int  _inputTypeID           = 0;
            int  _ValidationTypeID      = 8;
            int  _attributeSetGroupID   = 0;
            bool _isIncludeInPriceRule  = false;
            bool _isIncludeInPromotions = false;
            int  _displayOrder          = 0;

            string sku               = "";
            string activeFrom        = "";
            string activeTo          = "";
            string hidePrice         = "";
            string isHideInRSS       = "";
            string isHideToAnonymous = "";

            bool   toInsertIntoDB    = true;
            bool   isFormValid       = true;
            string imageVar          = string.Empty;
            int    imageCounterFirst = 0;

            ItemsManagementSqlProvider obj = new ItemsManagementSqlProvider();
            var formVars = JSONHelper.Deserialise <List <AspxNameValue> >(itemObj.FormVars);

            //    for (int i = 0; i < formVars.Length; i++)
            for (int i = 0; i < formVars.Count; i++)
            {
                string attribValue = formVars[i].value;
                //string jsonResult = formVars[i].name.Replace('%', '_');
                string         jsonResult     = formVars[i].name.Replace('-', ' ');
                string[]       jsonVar        = jsonResult.Split('_');
                FormValidation formValidation = new FormValidation();

                if (jsonVar.Length > 1)
                {
                    _attributeID           = Int32.Parse(jsonVar[0]);
                    _inputTypeID           = Int32.Parse(jsonVar[1]);
                    _ValidationTypeID      = Int32.Parse(jsonVar[2]);
                    _attributeSetGroupID   = Int32.Parse(jsonVar[4]);
                    _isIncludeInPriceRule  = bool.Parse(jsonVar[5]);
                    _isIncludeInPromotions = bool.Parse(jsonVar[6]);
                    _displayOrder          = Int32.Parse(jsonVar[7]);

                    //Save To Database 1. [aspx_Items] 2. Others
                    if (_attributeID == 4)
                    {
                        sku = formVars[i].value;
                    }
                    else if (_attributeID == 22)
                    {
                        activeFrom = formVars[i].value;
                    }
                    else if (_attributeID == 23)
                    {
                        activeTo = formVars[i].value;
                    }
                    else if (_attributeID == 26)
                    {
                        hidePrice = formVars[i].value;
                    }
                    else if (_attributeID == 27)
                    {
                        isHideInRSS = formVars[i].value;
                    }
                    else if (_attributeID == 28)
                    {
                        isHideToAnonymous = formVars[i].value;
                    }


                    if (itemObj.ItemId == 0 && updateFlag == false)
                    {
                        itemObj.ItemId = obj.AddItem(itemObj, aspxCommonObj, true, isModified, sku, activeFrom, activeTo,
                                                     hidePrice, isHideInRSS, isHideToAnonymous, updateFlag);
                    }
                    else if (itemObj.ItemId > 0 && i == (formVars.Count - 1))
                    {
                        itemObj.ItemId = obj.AddItem(itemObj, aspxCommonObj, true, isModified, sku, activeFrom, activeTo,
                                                     hidePrice, isHideInRSS, isHideToAnonymous, updateFlag);
                    }
                    if (itemObj.ItemId > 0)
                    {
                        if (_inputTypeID == 1)
                        {
                            if (_ValidationTypeID == 3)
                            {
                                if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                                {
                                    attribValue = formVars[i].value;
                                }
                                else
                                {
                                    isFormValid = false;
                                    break;
                                }
                            }
                            else if (_ValidationTypeID == 5)
                            {
                                if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                                {
                                    attribValue = formVars[i].value;
                                }
                                else
                                {
                                    isFormValid = false;
                                    break;
                                }
                            }
                            else
                            {
                                if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                                {
                                    attribValue = formVars[i].value;
                                }
                                else
                                {
                                    isFormValid = false;
                                    break;
                                }
                            }
                        }
                        else if (_inputTypeID == 2)
                        {
                            if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                            {
                                attribValue = formVars[i].value;
                            }
                            else
                            {
                                isFormValid = false;
                                break;
                            }
                        }
                        else if (_inputTypeID == 3)
                        {
                            if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                            {
                                if (!string.IsNullOrEmpty(formVars[i].value))
                                {
                                    attribValue = formVars[i].value;
                                }
                            }
                            else
                            {
                                isFormValid = false;
                                break;
                            }
                        }
                        else if (_inputTypeID == 4)
                        {
                            if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                            {
                                if (!string.IsNullOrEmpty(formVars[i].value))
                                {
                                    attribValue = formVars[i].value;
                                }
                            }
                            else
                            {
                                isFormValid = false;
                                break;
                            }
                        }
                        else if (_inputTypeID == 5 || _inputTypeID == 6 || _inputTypeID == 9 || _inputTypeID == 10 ||
                                 _inputTypeID == 11 || _inputTypeID == 12)
                        {
                            if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                            {
                                attribValue = formVars[i].value;
                            }
                            else
                            {
                                isFormValid = false;
                                break;
                            }
                        }
                        else if (_inputTypeID == 7)
                        {
                            if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                            {
                                attribValue = formVars[i].value;
                            }
                            else
                            {
                                isFormValid = false;
                                break;
                            }
                        }

                        else if (_inputTypeID == 8)
                        {
                            if (imageCounterFirst % 2 == 0)
                            {
                                toInsertIntoDB = false;
                                if (!string.IsNullOrEmpty(formVars[i].value) &&
                                    formVars[i].value.ToLower() != "undefined")
                                {
                                    if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID,
                                                                     formVars[i].value))
                                    {
                                        imageVar = attribValue;
                                    }
                                    else
                                    {
                                        isFormValid = false;
                                        break;
                                    }
                                }
                                else
                                {
                                    imageVar = "";
                                }
                            }
                            else
                            {
                                toInsertIntoDB = true;

                                if (attribValue != imageVar)
                                {
                                    //_imageVar = _imageVar.Replace("../", "");
                                    imageVar = imageVar.Replace("/", "\\");
                                    //attribValue = attribValue.Replace("../", "");
                                    attribValue = attribValue.Replace("/", "\\");

                                    string tempFolder            = @"Upload\temp";
                                    FileHelperController fileObj = new FileHelperController();
                                    attribValue = fileObj.MoveFileToModuleFolder(tempFolder, attribValue, imageVar,
                                                                                 itemLargeThumbNailSize,
                                                                                 itemMediumThumbNailSize,
                                                                                 itemSmallThumbNailSize,
                                                                                 @"Modules\AspxCommerce\AspxItemsManagement\uploads\",
                                                                                 itemObj.ItemId, "item_");
                                }
                            }
                            imageCounterFirst++;
                        }
                    }
                    if (isFormValid && toInsertIntoDB)
                    {
                        obj.SaveUpdateItemAttributes(itemObj.ItemId, itemObj.AttributeSetId, aspxCommonObj, true,
                                                     isModified,
                                                     attribValue,
                                                     _attributeID, _inputTypeID, _ValidationTypeID, _attributeSetGroupID,
                                                     _isIncludeInPriceRule, _isIncludeInPromotions,
                                                     _displayOrder);
                    }
                }
            }
            if (itemObj.ItemTypeId == 1 || itemObj.ItemTypeId == 2)
            {
                obj.InsertBrandMapping(itemObj.ItemId, itemObj.BrandId, storeId, portalId, userName, culture);
            }
            if (itemObj.ItemVideoIDs != "" || updateFlag == true)
            {
                obj.InsertAndUpdateItemVideos(itemObj.ItemId, itemObj.ItemVideoIDs, aspxCommonObj);
            }
            return(itemObj.ItemId);
        }
 public List<CategoryInfo> GetCategoryList(string prefix, bool isActive, string cultureName, Int32 storeID, Int32 portalID, string userName, int itemId)
 {
     ItemsManagementSqlProvider obj = new ItemsManagementSqlProvider();
     List<CategoryInfo> catList = obj.GetCategoryList(prefix, isActive, cultureName, storeID, portalID, userName, itemId);
     return catList;
 }
 public List<LowStockItemsInfo> GetLowStockItemsList(int offset, System.Nullable<int> limit, string sku, string name, System.Nullable<bool> isActive, int storeId, int portalId, string userName, string cultureName, int lowStock)
 {
     try
     {
         ItemsManagementSqlProvider obj = new ItemsManagementSqlProvider();
         return obj.GetAllLowStockItems(offset, limit, sku, name, isActive, storeId, portalId, userName, cultureName, lowStock);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public bool CheckUniqueItemSKUCode(string SKU, int itemId, int storeId, int portalId, string cultureName)
 {
     try
     {
         ItemsManagementSqlProvider obj = new ItemsManagementSqlProvider();
         return obj.CheckUniqueSKUCode(SKU, itemId, storeId, portalId, cultureName);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public List<OrderItemsGroupByItemIDInfo> GetOrderedItemsList(int offset, System.Nullable<int> limit, string name, int storeId, int portalId, string userName, string cultureName)
 {
     try
     {
         ItemsManagementSqlProvider obj = new ItemsManagementSqlProvider();
         return obj.GetOrderedItemsList(offset, limit, name, storeId, portalId, userName, cultureName);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public List<ItemsInfo> GetCrossSellItemsList(int offset, int limit, int storeId, int portalId, int selfItemId, string userName, string culture)
 {
     try
     {
         ItemsManagementSqlProvider obj = new ItemsManagementSqlProvider();
         return obj.GetCrossSellItemsByItemID(offset, limit, storeId, portalId, selfItemId, userName, culture);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public List<DownLoadableItemGetInfo> GetDownLoadableItemsList(int offset, System.Nullable<int> limit, string sku, string name, int storeId, int portalId, string userName, string cultureName, System.Nullable<bool> CheckUser)
 {
     try
     {
         ItemsManagementSqlProvider obj = new ItemsManagementSqlProvider();
         return obj.GetDownLoadableItemsList(offset, limit, sku, name, storeId, portalId, userName, cultureName, CheckUser);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public int SaveUpdateItemAndAttributes(ItemsInfo.ItemSaveBasicInfo itemObj, AspxCommonInfo aspxCommonObj)
        {
            bool isModified = false;
            bool updateFlag = false;
            int storeId = aspxCommonObj.StoreID;
            int portalId = aspxCommonObj.PortalID;
            string culture = aspxCommonObj.CultureName;
            string userName = aspxCommonObj.UserName;
            if (itemObj.ItemId > 0)
            {
                isModified = true;
                updateFlag = true;
            }
            StoreSettingConfig ssc = new StoreSettingConfig();
            int itemLargeThumbNailHeight =
                Convert.ToInt32(ssc.GetStoreSettingsByKey(StoreSetting.ItemLargeThumbnailImageHeight, storeId, portalId, culture));
            int itemLargeThumbNailWidth =
                Convert.ToInt32(ssc.GetStoreSettingsByKey(StoreSetting.ItemLargeThumbnailImageWidth, storeId, portalId, culture));
            int itemMediumThumbNailHeight =
                Convert.ToInt32(ssc.GetStoreSettingsByKey(StoreSetting.ItemMediumThumbnailImageHeight, storeId, portalId, culture));
            int itemMediumThumbNailWidth =
               Convert.ToInt32(ssc.GetStoreSettingsByKey(StoreSetting.ItemMediumThumbnailImageWidth, storeId, portalId, culture));
            int itemSmallThumbNailHeight =
                Convert.ToInt32(ssc.GetStoreSettingsByKey(StoreSetting.ItemSmallThumbnailImageHeight, storeId, portalId, culture));
            int itemSmallThumbNailWidth =
                Convert.ToInt32(ssc.GetStoreSettingsByKey(StoreSetting.ItemSmallThumbnailImageWidth, storeId, portalId, culture));
            int _attributeID = 0;
            int _inputTypeID = 0;
            int _ValidationTypeID = 8;
            int _attributeSetGroupID = 0;
            bool _isIncludeInPriceRule = false;
            bool _isIncludeInPromotions = false;
            int _displayOrder = 0;

            string sku = "";
            string activeFrom = "";
            string activeTo = "";
            string hidePrice = "";
            string isHideInRSS = "";
            string isHideToAnonymous = "";

            bool toInsertIntoDB = true;
            bool isFormValid = true;
            string imageVar = string.Empty;
            int imageCounterFirst = 0;

            ItemsManagementSqlProvider obj = new ItemsManagementSqlProvider();
            var formVars = JSONHelper.Deserialise<List<AspxNameValue>>(itemObj.FormVars);
            //    for (int i = 0; i < formVars.Length; i++)
            for (int i = 0; i < formVars.Count; i++)
            {
                string attribValue = formVars[i].value;
                //string jsonResult = formVars[i].name.Replace('%', '_');
                string jsonResult = formVars[i].name.Replace('-', ' ');
                string[] jsonVar = jsonResult.Split('_');
                FormValidation formValidation = new FormValidation();

                if (jsonVar.Length > 1)
                {
                    _attributeID = Int32.Parse(jsonVar[0]);
                    _inputTypeID = Int32.Parse(jsonVar[1]);
                    _ValidationTypeID = Int32.Parse(jsonVar[2]);
                    _attributeSetGroupID = Int32.Parse(jsonVar[4]);
                    _isIncludeInPriceRule = bool.Parse(jsonVar[5]);
                    _isIncludeInPromotions = bool.Parse(jsonVar[6]);
                    _displayOrder = Int32.Parse(jsonVar[7]);

                    //Save To Database 1. [aspx_Items] 2. Others 
                    if (_attributeID == 4)
                    {
                        sku = formVars[i].value;
                    }
                    else if (_attributeID == 22)
                    {
                        activeFrom = formVars[i].value;
                    }
                    else if (_attributeID == 23)
                    {
                        activeTo = formVars[i].value;
                    }
                    else if (_attributeID == 26)
                    {
                        hidePrice = formVars[i].value;
                    }
                    else if (_attributeID == 27)
                    {
                        isHideInRSS = formVars[i].value;
                    }
                    else if (_attributeID == 28)
                    {
                        isHideToAnonymous = formVars[i].value;
                    }


                    if (itemObj.ItemId == 0 && updateFlag == false)
                    {
                        itemObj.ItemId = obj.AddItem(itemObj, aspxCommonObj, true, isModified, sku, activeFrom, activeTo,
                                                     hidePrice, isHideInRSS, isHideToAnonymous, updateFlag);
                    }
                    else if (itemObj.ItemId > 0 && i == (formVars.Count - 1))
                    {
                        itemObj.ItemId = obj.AddItem(itemObj, aspxCommonObj, true, isModified, sku, activeFrom, activeTo,
                                                     hidePrice, isHideInRSS, isHideToAnonymous, updateFlag);
                    }
                    if (itemObj.ItemId > 0)
                    {
                        if (_inputTypeID == 1)
                        {
                            if (_ValidationTypeID == 3)
                            {
                                if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                                {
                                    attribValue = formVars[i].value;
                                }
                                else
                                {
                                    isFormValid = false;
                                    break;
                                }
                            }
                            else if (_ValidationTypeID == 5)
                            {
                                if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                                {
                                    attribValue = formVars[i].value;
                                }
                                else
                                {
                                    isFormValid = false;
                                    break;
                                }
                            }
                            else
                            {
                                if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                                {
                                    attribValue = formVars[i].value;
                                }
                                else
                                {
                                    isFormValid = false;
                                    break;
                                }
                            }
                        }
                        else if (_inputTypeID == 2)
                        {
                            if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                            {
                                attribValue = formVars[i].value;
                            }
                            else
                            {
                                isFormValid = false;
                                break;
                            }
                        }
                        else if (_inputTypeID == 3)
                        {
                            if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                            {
                                if (!string.IsNullOrEmpty(formVars[i].value))
                                {
                                    attribValue = formVars[i].value;
                                }
                            }
                            else
                            {
                                isFormValid = false;
                                break;
                            }
                        }
                        else if (_inputTypeID == 4)
                        {
                            if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                            {
                                if (!string.IsNullOrEmpty(formVars[i].value))
                                {
                                    attribValue = formVars[i].value;
                                }
                            }
                            else
                            {
                                isFormValid = false;
                                break;
                            }
                        }
                        else if (_inputTypeID == 5 || _inputTypeID == 6 || _inputTypeID == 9 || _inputTypeID == 10 ||
                                 _inputTypeID == 11 || _inputTypeID == 12)
                        {
                            if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                            {
                                attribValue = formVars[i].value;
                            }
                            else
                            {
                                isFormValid = false;
                                break;
                            }
                        }
                        else if (_inputTypeID == 7)
                        {
                            if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                            {
                                attribValue = formVars[i].value;
                            }
                            else
                            {
                                isFormValid = false;
                                break;
                            }
                        }

                        else if (_inputTypeID == 8)
                        {
                            if (imageCounterFirst % 2 == 0)
                            {
                                toInsertIntoDB = false;
                                if (!string.IsNullOrEmpty(formVars[i].value) &&
                                    formVars[i].value.ToLower() != "undefined")
                                {
                                    if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID,
                                                                     formVars[i].value))
                                    {
                                        imageVar = attribValue;
                                    }
                                    else
                                    {
                                        isFormValid = false;
                                        break;
                                    }
                                }
                                else
                                {
                                    imageVar = "";
                                }
                            }
                            else
                            {
                                toInsertIntoDB = true;

                                if (attribValue != imageVar)
                                {
                                    //_imageVar = _imageVar.Replace("../", "");
                                    imageVar = imageVar.Replace("/", "\\");
                                    //attribValue = attribValue.Replace("../", "");
                                    attribValue = attribValue.Replace("/", "\\");

                                    string tempFolder = @"Upload\temp";
                                    FileHelperController fileObj = new FileHelperController();
                                    attribValue = fileObj.MoveFileToModuleFolder(tempFolder, attribValue, imageVar,
                                                                                 itemLargeThumbNailHeight,
                                                                                  itemLargeThumbNailWidth,
                                                                                 itemMediumThumbNailHeight,
                                                                                  itemMediumThumbNailWidth,
                                                                                 itemSmallThumbNailHeight,
                                                                                  itemSmallThumbNailWidth,
                                                                                 @"Modules\AspxCommerce\AspxItemsManagement\uploads\",
                                                                                 itemObj.ItemId, "item_");
                                    
                                }
                            }
                            imageCounterFirst++;
                        }
                    }
                    if (isFormValid && toInsertIntoDB)
                    {
                        obj.SaveUpdateItemAttributes(itemObj.ItemId, itemObj.AttributeSetId, aspxCommonObj, true,
                                                     isModified,
                                                     attribValue,
                                                     _attributeID, _inputTypeID, _ValidationTypeID, _attributeSetGroupID,
                                                     _isIncludeInPriceRule, _isIncludeInPromotions,
                                                     _displayOrder);

                    }
                }
            }
            if (itemObj.ItemTypeId == 1 || itemObj.ItemTypeId == 2)
            {
                obj.InsertBrandMapping(itemObj.ItemId, itemObj.BrandId, storeId, portalId, userName, culture);
            }
            if (itemObj.ItemVideoIDs != "" || updateFlag == true)
                obj.InsertAndUpdateItemVideos(itemObj.ItemId, itemObj.ItemVideoIDs, aspxCommonObj);
            return itemObj.ItemId;
        }
 public List<MostViewedItemsInfo> GetMostViewedItemsList(int offset, int limit, string name, int storeId, int portalId, string userName, string cultureName)
 {
     try
     {
         ItemsManagementSqlProvider obj = new ItemsManagementSqlProvider();
         return obj.GetAllMostViewedItems(offset, limit, name, storeId, portalId, userName, cultureName);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }