public CategoryInfo SaveCategory(Int32 storeID, Int32 portalID, Int32 categoryID, Int32 parentID, AspxNameValue[] formVars, string selectedItems, string userName, string culture, int categoryLargeThumbImage, int categoryMediumThumbImage, int categorySmallThumbImage)
        {
            try
            {
                CategoryInfo categoryInfo = new CategoryInfo();
                FormValidation formValidation = new FormValidation();
                List<CategoryAttributeInfo> listCategoryAttributes = new List<CategoryAttributeInfo>();
                categoryInfo.CategoryID = categoryID;
                categoryInfo.ParentID = parentID;
                categoryInfo.IsShowInCatalog = true;
                categoryInfo.IsShowInMenu = true;
                categoryInfo.IsShowInSearch = true;
                categoryInfo.PortalID = portalID;
                categoryInfo.StoreID = storeID;
                categoryInfo.ActiveFrom = new DateTime(1970, 1, 1);
                categoryInfo.ActiveTo = new DateTime(2999, 12, 30);
                bool toInsertIntoDB = true;
                bool isFormValid = true;
                //int _imageCounter = 0;
                string imageVar = string.Empty;
                int imageCounterFirst = 0;

                for (int i = 0; i < formVars.Length; i++)
                {
                    int inputTypeID;
                    int validationTypeID;
                    string attribName = formVars[i].name;
                    string attribValue = formVars[i].value;
                    string jsonResult = formVars[i].name.Replace('-', ' ');
                    string[] jsonVar = jsonResult.Split('_');

                    CategoryAttributeInfo categoryAttribute = new CategoryAttributeInfo();
                    categoryAttribute.AttributeID = int.Parse(jsonVar[0]);
                    inputTypeID = int.Parse(jsonVar[1]);
                    validationTypeID = int.Parse(jsonVar[2]);
                    if (inputTypeID == 1)
                    {
                        if (validationTypeID == 3)
                        {
                            if (formValidation.ValidateValue(attribName, validationTypeID, attribValue))
                            {
                                categoryAttribute.InputTypeID = inputTypeID;
                                categoryAttribute.ValidationTypeID = validationTypeID;
                                categoryAttribute.DecimalValue = decimal.Parse(attribValue);
                            }
                            else
                            {
                                isFormValid = false;
                                break;
                            }
                        }
                        else if (validationTypeID == 5)
                        {
                            if (formValidation.ValidateValue(attribName, validationTypeID, attribValue))
                            {
                                categoryAttribute.InputTypeID = inputTypeID;
                                categoryAttribute.ValidationTypeID = validationTypeID;
                                categoryAttribute.IntValue = Int32.Parse(attribValue);
                            }
                            else
                            {
                                isFormValid = false;
                                break;
                            }
                        }
                        else
                        {
                            if (formValidation.ValidateValue(attribName, validationTypeID, attribValue))
                            {
                                categoryAttribute.InputTypeID = inputTypeID;
                                categoryAttribute.ValidationTypeID = validationTypeID;
                                categoryAttribute.NvarcharValue = attribValue;
                            }
                            else
                            {
                                isFormValid = false;
                                break;
                            }
                        }
                    }
                    else if (inputTypeID == 2)
                    {
                        if (formValidation.ValidateValue(attribName, validationTypeID, attribValue))
                        {
                            categoryAttribute.InputTypeID = inputTypeID;
                            categoryAttribute.ValidationTypeID = validationTypeID;
                            categoryAttribute.TextValue = attribValue;
                        }
                        else
                        {
                            isFormValid = false;
                            break;
                        }
                    }
                    else if (inputTypeID == 3)
                    {
                        if (formValidation.ValidateValue(attribName, validationTypeID, attribValue))
                        {
                            categoryAttribute.InputTypeID = inputTypeID;
                            categoryAttribute.ValidationTypeID = validationTypeID;
                            if (!string.IsNullOrEmpty(attribValue))
                            {
                                categoryAttribute.DateValue = DateTime.Parse(attribValue);
                            }
                        }
                        else
                        {
                            isFormValid = false;
                            break;
                        }
                    }
                    else if (inputTypeID == 4)
                    {
                        if (formValidation.ValidateValue(attribName, validationTypeID, attribValue))
                        {
                            categoryAttribute.InputTypeID = inputTypeID;
                            categoryAttribute.ValidationTypeID = validationTypeID;
                            if (!string.IsNullOrEmpty(attribValue))
                            {
                                categoryAttribute.BooleanValue = (attribValue == "1" ||
                                                                  attribValue.ToLower() == "true")
                                                                     ? true
                                                                     : false;
                            }
                            else
                            {
                                categoryAttribute.BooleanValue = false;
                            }
                        }
                        else
                        {
                            isFormValid = false;
                            break;
                        }
                    }
                    else if (inputTypeID == 5 || inputTypeID == 6 || inputTypeID == 9 || inputTypeID == 10 ||
                             inputTypeID == 11 || inputTypeID == 12)
                    {
                        if (formValidation.ValidateValue(attribName, validationTypeID, attribValue))
                        {
                            categoryAttribute.InputTypeID = inputTypeID;
                            categoryAttribute.ValidationTypeID = validationTypeID;
                            categoryAttribute.OptionValues = attribValue;
                        }
                        else
                        {
                            isFormValid = false;
                            break;
                        }
                    }
                    else if (inputTypeID == 7)
                    {
                        if (formValidation.ValidateValue(attribName, validationTypeID, attribValue))
                        {
                            categoryAttribute.InputTypeID = inputTypeID;
                            categoryAttribute.ValidationTypeID = validationTypeID;
                            categoryAttribute.DecimalValue = decimal.Parse(attribValue);
                        }
                        else
                        {
                            isFormValid = false;
                            break;
                        }
                    }
                    else if (inputTypeID == 8)
                    {
                        if (imageCounterFirst % 2 == 0)
                        {
                            toInsertIntoDB = false;
                            if (!string.IsNullOrEmpty(attribValue) && attribValue.ToLower() != "undefined")
                            {
                                if (formValidation.ValidateValue(attribName, validationTypeID, attribValue))
                                {
                                    imageVar = attribValue;
                                }
                                else
                                {

                                    isFormValid = false;
                                    break;
                                }
                            }
                            else
                            {
                                imageVar = "";
                            }
                        }
                        else
                        {
                            toInsertIntoDB = true;

                            categoryAttribute.InputTypeID = inputTypeID;
                            categoryAttribute.ValidationTypeID = validationTypeID;
                            //_imageVar = _imageVar.Replace("../", "");

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

                                string tempFolder = @"Upload\temp";
                                FileHelperController fileObj = new FileHelperController();
                                attribValue = fileObj.MoveFileToModuleFolder(tempFolder, attribValue, imageVar,categoryLargeThumbImage,categoryMediumThumbImage,categorySmallThumbImage,
                                                                             @"Modules\AspxCommerce\AspxCategoryManagement\uploads\",
                                                                             categoryID, "cat_");
                                categoryAttribute.FileValue = attribValue;
                            }
                            //else if (_imageVar == "")
                            //{
                            //    categoryAttribute.FileValue = _imageVar;
                            //}
                            else
                            {
                                categoryAttribute.FileValue = attribValue;
                            }
                        }
                        imageCounterFirst++;
                    }
                    if (toInsertIntoDB)
                    {
                        listCategoryAttributes.Add(categoryAttribute);
                    }
                }

                if (isFormValid)
                {
                    CategorySqlProvider categorySqlProvider = new CategorySqlProvider();
                    categoryInfo = categorySqlProvider.CategoryAddUpdate(categoryInfo, selectedItems, listCategoryAttributes, userName, culture);
                }
                else
                {
                    throw new Exception("Form is not valid one");
                }
                return categoryInfo;
            }
            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 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);
        }
Example #4
0
        public static int SaveCategory(CategoryInfo.CategorySaveBasicInfo categoryObj, AspxCommonInfo aspxCommonObj)
        {
            try
            {
                int            catID;
                CategoryInfo   categoryInfo   = new CategoryInfo();
                FormValidation formValidation = new FormValidation();
                List <CategoryAttributeInfo> listCategoryAttributes = new List <CategoryAttributeInfo>();
                categoryInfo.CategoryID      = categoryObj.CategoryId; //categoryID;
                categoryInfo.ParentID        = categoryObj.ParentId;   //parentID;
                categoryInfo.IsShowInCatalog = true;
                categoryInfo.IsShowInMenu    = true;
                categoryInfo.IsShowInSearch  = true;
                categoryInfo.PortalID        = aspxCommonObj.PortalID;
                categoryInfo.StoreID         = aspxCommonObj.StoreID;
                categoryInfo.ActiveFrom      = new DateTime(1970, 1, 1);
                categoryInfo.ActiveTo        = new DateTime(2999, 12, 30);
                categoryInfo.SelectedItems   = categoryObj.SelectedItems;
                bool toInsertIntoDB = true;
                bool isFormValid    = true;
                //int _imageCounter = 0;
                string imageVar          = string.Empty;
                int    imageCounterFirst = 0;

                var formVarss = JSONHelper.Deserialise <List <AspxNameValue> >(categoryObj.FormVars);


                foreach (var formVars in formVarss)
                {
                    int      inputTypeID;
                    int      validationTypeID;
                    string   attribName  = formVars.name;
                    string   attribValue = formVars.value;
                    string   jsonResult  = formVars.name.Replace('-', ' ');
                    string[] jsonVar     = jsonResult.Split('_');

                    CategoryAttributeInfo categoryAttribute = new CategoryAttributeInfo();
                    categoryAttribute.AttributeID = int.Parse(jsonVar[0]);
                    inputTypeID      = int.Parse(jsonVar[1]);
                    validationTypeID = int.Parse(jsonVar[2]);

                    categoryAttribute.InputTypeID      = inputTypeID;
                    categoryAttribute.ValidationTypeID = validationTypeID;
                    int _attributeID = categoryAttribute.AttributeID;
                    if (_attributeID == 36)
                    {
                        categoryInfo.IsService = int.Parse(formVars.value) != 9;
                    }
                    else if (_attributeID == 1)
                    {
                        categoryInfo.CategoryName = formVars.value;
                    }
                    else if (_attributeID == 9)
                    {
                        categoryInfo.MetaTitle = formVars.value;
                    }
                    else if (_attributeID == 2)
                    {
                        categoryInfo.Description = formVars.value;
                    }
                    else if (_attributeID == 3)
                    {
                        categoryInfo.ShortDescription = formVars.value;
                    }
                    else if (_attributeID == 10)
                    {
                        categoryInfo.MetaKeyword = formVars.value;
                    }
                    else if (_attributeID == 11)
                    {
                        categoryInfo.MetaDescription = formVars.value;
                    }
                    else if (_attributeID == 16)
                    {
                        categoryInfo.IsShowInMenu = bool.Parse(formVars.value);
                    }
                    else if (_attributeID == 17)
                    {
                        categoryInfo.IsShowInSearch = bool.Parse(formVars.value);
                    }
                    else if (_attributeID == 18)
                    {
                        categoryInfo.IsShowInCatalog = bool.Parse(formVars.value);
                    }
                    else if (_attributeID == 19)
                    {
                        categoryInfo.ActiveFrom = DateTime.Parse(formVars.value);
                    }
                    else if (_attributeID == 20)
                    {
                        categoryInfo.ActiveTo = DateTime.Parse(formVars.value);
                    }
                    else if (_attributeID == 12 || _attributeID == 21 || _attributeID == 22)
                    {
                        string _imagePath = string.Empty;
                        if (imageCounterFirst % 2 == 0)
                        {
                            toInsertIntoDB = false;
                            if (!string.IsNullOrEmpty(attribValue) && attribValue.ToLower() != "undefined")
                            {
                                if (formValidation.ValidateValue(attribName, validationTypeID, attribValue))
                                {
                                    imageVar = attribValue;
                                }
                                else
                                {
                                    isFormValid = false;
                                    break;
                                }
                            }
                            else
                            {
                                imageVar = "";
                            }
                        }
                        else
                        {
                            toInsertIntoDB = true;

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

                                string tempFolder            = @"Upload\temp";
                                FileHelperController fileObj = new FileHelperController();
                                attribValue = fileObj.MoveFileToModuleFolder(tempFolder, attribValue, imageVar,
                                                                             categoryObj.LargeThumbNailImageSize,
                                                                             categoryObj.MediumImageSize,
                                                                             categoryObj.SmallImageSize,
                                                                             @"Modules\AspxCommerce\AspxCategoryManagement\uploads\",
                                                                             categoryObj.CategoryId, "cat_");
                                attribValue =
                                    attribValue.Replace("Modules/AspxCommerce/AspxCategoryManagement/uploads/Small/", "");
                                _imagePath = attribValue;
                            }
                            //else if (_imageVar == "")
                            //{
                            //    categoryAttribute.FileValue = _imageVar;
                            //}
                            else
                            {
                                _imagePath = attribValue;
                            }
                        }
                        imageCounterFirst++;
                        if (toInsertIntoDB)
                        {
                            if (_attributeID == 12)
                            {
                                categoryInfo.CategoryBaseImage = _imagePath;
                            }
                            else if (_attributeID == 21)
                            {
                                categoryInfo.CategoryThumbnailImage = _imagePath;
                            }
                            else if (_attributeID == 22)
                            {
                                categoryInfo.CategorySmallImage = _imagePath;
                            }
                            //listCategoryAttributes.Add(categoryAttribute);
                        }
                    }
                    else if (categoryAttribute.AttributeID > 43)
                    {
                        if (categoryInfo.HasSystemAttribute)
                        {
                            categoryInfo.HasSystemAttribute = false;
                        }
                        if (inputTypeID == 1)
                        {
                            if (validationTypeID == 3)
                            {
                                if (formValidation.ValidateValue(attribName, validationTypeID, attribValue))
                                {
                                    categoryAttribute.DecimalValue = decimal.Parse(attribValue);
                                }
                                else
                                {
                                    isFormValid = false;
                                    break;
                                }
                            }
                            else if (validationTypeID == 5)
                            {
                                if (formValidation.ValidateValue(attribName, validationTypeID, attribValue))
                                {
                                    categoryAttribute.IntValue = Int32.Parse(attribValue);
                                }
                                else
                                {
                                    isFormValid = false;
                                    break;
                                }
                            }
                            else
                            {
                                if (formValidation.ValidateValue(attribName, validationTypeID, attribValue))
                                {
                                    categoryAttribute.NvarcharValue = attribValue;
                                }
                                else
                                {
                                    isFormValid = false;
                                    break;
                                }
                            }
                        }
                        else if (inputTypeID == 2)
                        {
                            if (formValidation.ValidateValue(attribName, validationTypeID, attribValue))
                            {
                                categoryAttribute.TextValue = attribValue;
                            }
                            else
                            {
                                isFormValid = false;
                                break;
                            }
                        }
                        else if (inputTypeID == 3)
                        {
                            if (formValidation.ValidateValue(attribName, validationTypeID, attribValue))
                            {
                                if (!string.IsNullOrEmpty(attribValue))
                                {
                                    categoryAttribute.DateValue = DateTime.Parse(attribValue);
                                }
                            }
                            else
                            {
                                isFormValid = false;
                                break;
                            }
                        }
                        else if (inputTypeID == 4)
                        {
                            if (formValidation.ValidateValue(attribName, validationTypeID, attribValue))
                            {
                                if (!string.IsNullOrEmpty(attribValue))
                                {
                                    categoryAttribute.BooleanValue = (attribValue == "1" ||
                                                                      attribValue.ToLower() == "true")
                                                                        ? true
                                                                        : false;
                                }
                                else
                                {
                                    categoryAttribute.BooleanValue = false;
                                }
                            }
                            else
                            {
                                isFormValid = false;
                                break;
                            }
                        }
                        else if (inputTypeID == 5 || inputTypeID == 6 || inputTypeID == 9 || inputTypeID == 10 ||
                                 inputTypeID == 11 || inputTypeID == 12)
                        {
                            if (formValidation.ValidateValue(attribName, validationTypeID, attribValue))
                            {
                                categoryAttribute.OptionValues = attribValue;
                            }
                            else
                            {
                                isFormValid = false;
                                break;
                            }
                        }
                        else if (inputTypeID == 7)
                        {
                            if (formValidation.ValidateValue(attribName, validationTypeID, attribValue))
                            {
                                categoryAttribute.DecimalValue = decimal.Parse(attribValue);
                            }
                            else
                            {
                                isFormValid = false;
                                break;
                            }
                        }
                        else if (inputTypeID == 8)
                        {
                            if (imageCounterFirst % 2 == 0)
                            {
                                toInsertIntoDB = false;
                                if (!string.IsNullOrEmpty(attribValue) && attribValue.ToLower() != "undefined")
                                {
                                    if (formValidation.ValidateValue(attribName, validationTypeID, attribValue))
                                    {
                                        imageVar = attribValue;
                                    }
                                    else
                                    {
                                        isFormValid = false;
                                        break;
                                    }
                                }
                                else
                                {
                                    imageVar = "";
                                }
                            }
                            else
                            {
                                toInsertIntoDB = true;

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

                                    string tempFolder            = @"Upload\temp";
                                    FileHelperController fileObj = new FileHelperController();
                                    attribValue = fileObj.MoveFileToModuleFolder(tempFolder, attribValue, imageVar,
                                                                                 categoryObj.LargeThumbNailImageSize,
                                                                                 categoryObj.MediumImageSize,
                                                                                 categoryObj.SmallImageSize,
                                                                                 @"Modules\AspxCommerce\AspxCategoryManagement\uploads\",
                                                                                 categoryObj.CategoryId, "cat_");
                                    categoryAttribute.FileValue = attribValue;
                                }
                                //else if (_imageVar == "")
                                //{
                                //    categoryAttribute.FileValue = _imageVar;
                                //}
                                else
                                {
                                    categoryAttribute.FileValue = attribValue;
                                }
                            }
                            imageCounterFirst++;
                        }
                        if (toInsertIntoDB)
                        {
                            listCategoryAttributes.Add(categoryAttribute);
                        }
                    }
                }
                if (isFormValid)
                {
                    string attributeIDs = "1,2,3,9,10,11,12,16,17,18,19,20,21,22,36";
                    catID = AspxCategoryManageProvider.CategoryAddUpdate(categoryInfo,
                                                                         listCategoryAttributes, aspxCommonObj.UserName,
                                                                         aspxCommonObj.CultureName, attributeIDs);
                }
                else
                {
                    throw new Exception("Form is not valid one");
                }
                return(catID);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Example #5
0
        //public int SaveCategory(Int32 storeID, Int32 portalID, Int32 categoryID, Int32 parentID, AspxNameValue[] formVars, string selectedItems, string userName, string culture, int categoryLargeThumbImage, int categoryMediumThumbImage, int categorySmallThumbImage)
        //{
        public int SaveCategory(CategoryInfo.CategorySaveBasicInfo categoryObj, AspxCommonInfo aspxCommonObj)
        {
            try
            {
                int            catID;
                CategoryInfo   categoryInfo   = new CategoryInfo();
                FormValidation formValidation = new FormValidation();
                List <CategoryAttributeInfo> listCategoryAttributes = new List <CategoryAttributeInfo>();
                categoryInfo.CategoryID      = categoryObj.CategoryId; //categoryID;
                categoryInfo.ParentID        = categoryObj.ParentId;   //parentID;
                categoryInfo.IsShowInCatalog = true;
                categoryInfo.IsShowInMenu    = true;
                categoryInfo.IsShowInSearch  = true;
                categoryInfo.PortalID        = aspxCommonObj.PortalID;
                categoryInfo.StoreID         = aspxCommonObj.StoreID;
                categoryInfo.ActiveFrom      = new DateTime(1970, 1, 1);
                categoryInfo.ActiveTo        = new DateTime(2999, 12, 30);
                bool toInsertIntoDB = true;
                bool isFormValid    = true;
                //int _imageCounter = 0;
                string imageVar          = string.Empty;
                int    imageCounterFirst = 0;

                var formVarss = JSONHelper.Deserialise <List <AspxNameValue> >(categoryObj.FormVars);


                foreach (var formVars in formVarss)
                {
                    int      inputTypeID;
                    int      validationTypeID;
                    string   attribName  = formVars.name;
                    string   attribValue = formVars.value;
                    string   jsonResult  = formVars.name.Replace('-', ' ');
                    string[] jsonVar     = jsonResult.Split('_');

                    CategoryAttributeInfo categoryAttribute = new CategoryAttributeInfo();
                    categoryAttribute.AttributeID = int.Parse(jsonVar[0]);
                    inputTypeID      = int.Parse(jsonVar[1]);
                    validationTypeID = int.Parse(jsonVar[2]);
                    if (inputTypeID == 1)
                    {
                        if (validationTypeID == 3)
                        {
                            if (formValidation.ValidateValue(attribName, validationTypeID, attribValue))
                            {
                                categoryAttribute.InputTypeID      = inputTypeID;
                                categoryAttribute.ValidationTypeID = validationTypeID;
                                categoryAttribute.DecimalValue     = decimal.Parse(attribValue);
                            }
                            else
                            {
                                isFormValid = false;
                                break;
                            }
                        }
                        else if (validationTypeID == 5)
                        {
                            if (formValidation.ValidateValue(attribName, validationTypeID, attribValue))
                            {
                                categoryAttribute.InputTypeID      = inputTypeID;
                                categoryAttribute.ValidationTypeID = validationTypeID;
                                categoryAttribute.IntValue         = Int32.Parse(attribValue);
                            }
                            else
                            {
                                isFormValid = false;
                                break;
                            }
                        }
                        else
                        {
                            if (formValidation.ValidateValue(attribName, validationTypeID, attribValue))
                            {
                                categoryAttribute.InputTypeID      = inputTypeID;
                                categoryAttribute.ValidationTypeID = validationTypeID;
                                categoryAttribute.NvarcharValue    = attribValue;
                            }
                            else
                            {
                                isFormValid = false;
                                break;
                            }
                        }
                    }
                    else if (inputTypeID == 2)
                    {
                        if (formValidation.ValidateValue(attribName, validationTypeID, attribValue))
                        {
                            categoryAttribute.InputTypeID      = inputTypeID;
                            categoryAttribute.ValidationTypeID = validationTypeID;
                            categoryAttribute.TextValue        = attribValue;
                        }
                        else
                        {
                            isFormValid = false;
                            break;
                        }
                    }
                    else if (inputTypeID == 3)
                    {
                        if (formValidation.ValidateValue(attribName, validationTypeID, attribValue))
                        {
                            categoryAttribute.InputTypeID      = inputTypeID;
                            categoryAttribute.ValidationTypeID = validationTypeID;
                            if (!string.IsNullOrEmpty(attribValue))
                            {
                                categoryAttribute.DateValue = DateTime.Parse(attribValue);
                            }
                        }
                        else
                        {
                            isFormValid = false;
                            break;
                        }
                    }
                    else if (inputTypeID == 4)
                    {
                        if (formValidation.ValidateValue(attribName, validationTypeID, attribValue))
                        {
                            categoryAttribute.InputTypeID      = inputTypeID;
                            categoryAttribute.ValidationTypeID = validationTypeID;
                            if (!string.IsNullOrEmpty(attribValue))
                            {
                                categoryAttribute.BooleanValue = (attribValue == "1" || attribValue.ToLower() == "true")? true: false;
                            }
                            else
                            {
                                categoryAttribute.BooleanValue = false;
                            }
                        }
                        else
                        {
                            isFormValid = false;
                            break;
                        }
                    }
                    else if (inputTypeID == 5 || inputTypeID == 6 || inputTypeID == 9 || inputTypeID == 10 ||
                             inputTypeID == 11 || inputTypeID == 12)
                    {
                        if (formValidation.ValidateValue(attribName, validationTypeID, attribValue))
                        {
                            categoryAttribute.InputTypeID      = inputTypeID;
                            categoryAttribute.ValidationTypeID = validationTypeID;
                            categoryAttribute.OptionValues     = attribValue;
                        }
                        else
                        {
                            isFormValid = false;
                            break;
                        }
                    }
                    else if (inputTypeID == 7)
                    {
                        if (formValidation.ValidateValue(attribName, validationTypeID, attribValue))
                        {
                            categoryAttribute.InputTypeID      = inputTypeID;
                            categoryAttribute.ValidationTypeID = validationTypeID;
                            categoryAttribute.DecimalValue     = decimal.Parse(attribValue);
                        }
                        else
                        {
                            isFormValid = false;
                            break;
                        }
                    }
                    else if (inputTypeID == 8)
                    {
                        if (imageCounterFirst % 2 == 0)
                        {
                            toInsertIntoDB = false;
                            if (!string.IsNullOrEmpty(attribValue) && attribValue.ToLower() != "undefined")
                            {
                                if (formValidation.ValidateValue(attribName, validationTypeID, attribValue))
                                {
                                    imageVar = attribValue;
                                }
                                else
                                {
                                    isFormValid = false;
                                    break;
                                }
                            }
                            else
                            {
                                imageVar = "";
                            }
                        }
                        else
                        {
                            toInsertIntoDB = true;

                            categoryAttribute.InputTypeID      = inputTypeID;
                            categoryAttribute.ValidationTypeID = validationTypeID;
                            //_imageVar = _imageVar.Replace("../", "");

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

                                string tempFolder            = @"Upload\temp";
                                FileHelperController fileObj = new FileHelperController();
                                //attribValue = fileObj.MoveFileToModuleFolder(tempFolder, attribValue, imageVar,categoryLargeThumbImage,categoryMediumThumbImage,categorySmallThumbImage,
                                //                                             @"Modules\AspxCommerce\AspxCategoryManagement\uploads\",
                                //                                             categoryID, "cat_");
                                attribValue = fileObj.MoveFileToModuleFolder(tempFolder, attribValue, imageVar,
                                                                             categoryObj.LargeThumbNailImageHeight,
                                                                             categoryObj.LargeThumbNailImageWidth,
                                                                             categoryObj.MediumImageHeight,
                                                                             categoryObj.MediumImageWidth,
                                                                             categoryObj.SmallImageHeight,
                                                                             categoryObj.SmallImageWidth,
                                                                             @"Modules\AspxCommerce\AspxCategoryManagement\uploads\",
                                                                             categoryObj.CategoryId, "cat_");
                                categoryAttribute.FileValue = attribValue;
                            }
                            //else if (_imageVar == "")
                            //{
                            //    categoryAttribute.FileValue = _imageVar;
                            //}
                            else
                            {
                                categoryAttribute.FileValue = attribValue;
                            }
                        }
                        imageCounterFirst++;
                    }
                    if (toInsertIntoDB)
                    {
                        listCategoryAttributes.Add(categoryAttribute);
                    }
                }

                if (isFormValid)
                {
                    CategorySqlProvider categorySqlProvider = new CategorySqlProvider();
                    //    categoryInfo = categorySqlProvider.CategoryAddUpdate(categoryInfo, selectedItems, listCategoryAttributes, userName, culture);
                    // catID = categorySqlProvider.CategoryAddUpdate(categoryInfo, selectedItems, listCategoryAttributes, userName, culture);
                    catID = categorySqlProvider.CategoryAddUpdate(categoryInfo, categoryObj.SelectedItems,
                                                                  listCategoryAttributes, aspxCommonObj.UserName,
                                                                  aspxCommonObj.CultureName);
                }
                else
                {
                    throw new Exception("Form is not valid one");
                }
                //return categoryInfo;
                return(catID);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
       public static int SaveCategory(CategoryInfo.CategorySaveBasicInfo categoryObj, AspxCommonInfo aspxCommonObj)
       {
           try
           {
               int catID;
               CategoryInfo categoryInfo = new CategoryInfo();
               FormValidation formValidation = new FormValidation();
               List<CategoryAttributeInfo> listCategoryAttributes = new List<CategoryAttributeInfo>();
               categoryInfo.CategoryID = categoryObj.CategoryId; //categoryID;
               categoryInfo.ParentID = categoryObj.ParentId; //parentID;
               categoryInfo.IsShowInCatalog = true;
               categoryInfo.IsShowInMenu = true;
               categoryInfo.IsShowInSearch = true;
               categoryInfo.PortalID = aspxCommonObj.PortalID;
               categoryInfo.StoreID = aspxCommonObj.StoreID;
               categoryInfo.ActiveFrom = new DateTime(1970, 1, 1);
               categoryInfo.ActiveTo = new DateTime(2999, 12, 30);
               categoryInfo.SelectedItems = categoryObj.SelectedItems;
               bool toInsertIntoDB = true;
               bool isFormValid = true;
               //int _imageCounter = 0;
               string imageVar = string.Empty;
               int imageCounterFirst = 0;

               var formVarss = JSONHelper.Deserialise<List<AspxNameValue>>(categoryObj.FormVars);


               foreach (var formVars in formVarss)
               {

                   int inputTypeID;
                   int validationTypeID;
                   string attribName = formVars.name;
                   string attribValue = formVars.value;
                   string jsonResult = formVars.name.Replace('-', ' ');
                   string[] jsonVar = jsonResult.Split('_');

                   CategoryAttributeInfo categoryAttribute = new CategoryAttributeInfo();
                   categoryAttribute.AttributeID = int.Parse(jsonVar[0]);
                   inputTypeID = int.Parse(jsonVar[1]);
                   validationTypeID = int.Parse(jsonVar[2]);

                   categoryAttribute.InputTypeID = inputTypeID;
                   categoryAttribute.ValidationTypeID = validationTypeID;
                   int _attributeID = categoryAttribute.AttributeID;
                   if (_attributeID == 36)
                   {
                       categoryInfo.IsService = int.Parse(formVars.value) != 9;
                   }
                   else if (_attributeID == 1)
                   {
                       categoryInfo.CategoryName = formVars.value;
                   }
                   else if (_attributeID == 9)
                   {
                       categoryInfo.MetaTitle = formVars.value;
                   }
                   else if (_attributeID == 2)
                   {
                       categoryInfo.Description = formVars.value;
                   }
                   else if (_attributeID == 3)
                   {
                       categoryInfo.ShortDescription = formVars.value;
                   }
                   else if (_attributeID == 10)
                   {
                       categoryInfo.MetaKeyword = formVars.value;
                   }
                   else if (_attributeID == 11)
                   {
                       categoryInfo.MetaDescription = formVars.value;
                   }
                   else if (_attributeID == 16)
                   {
                       categoryInfo.IsShowInMenu = bool.Parse(formVars.value);
                   }
                   else if (_attributeID == 17)
                   {
                       categoryInfo.IsShowInSearch = bool.Parse(formVars.value);
                   }
                   else if (_attributeID == 18)
                   {
                       categoryInfo.IsShowInCatalog = bool.Parse(formVars.value);
                   }
                   else if (_attributeID == 19)
                   {
                       categoryInfo.ActiveFrom = DateTime.Parse(formVars.value);
                   }
                   else if (_attributeID == 20)
                   {
                       categoryInfo.ActiveTo = DateTime.Parse(formVars.value);
                   }
                   else if (_attributeID == 12 || _attributeID == 21 || _attributeID == 22)
                   {
                       string _imagePath = string.Empty;
                       if (imageCounterFirst%2 == 0)
                       {
                           toInsertIntoDB = false;
                           if (!string.IsNullOrEmpty(attribValue) && attribValue.ToLower() != "undefined")
                           {
                               if (formValidation.ValidateValue(attribName, validationTypeID, attribValue))
                               {
                                   imageVar = attribValue;
                               }
                               else
                               {
                                   isFormValid = false;
                                   break;
                               }
                           }
                           else
                           {
                               imageVar = "";
                           }
                       }
                       else
                       {
                           toInsertIntoDB = true;
                           if (imageVar != "")
                           {
                               string[] strArray = imageVar.Split('/');
                               if (strArray[1] == "temp")
                               {
                                   if (attribValue != imageVar)
                                   {
                                       imageVar = imageVar.Replace("/", "\\");
                                       attribValue = attribValue.Replace("/", "\\");

                                       string tempFolder = @"Upload\temp";
                                       FileHelperController fileObj = new FileHelperController();
                                       attribValue = fileObj.MoveFileToModuleFoldr(tempFolder, attribValue, imageVar,
                                                                                    categoryObj.LargeThumbNailImageHeight,
                                                                                     categoryObj.LargeThumbNailImageWidth,
                                                                                    categoryObj.MediumImageHeight,
                                                                                    categoryObj.MediumImageWidth,
                                                                                    categoryObj.SmallImageHeight,
                                                                                    categoryObj.SmallImageWidth,
                                                                                    @"Modules\AspxCommerce\AspxCategoryManagement\uploads\",
                                                                                    categoryObj.CategoryId, "cat_");
                                       attribValue =
                                           attribValue.Replace("Modules/AspxCommerce/AspxCategoryManagement/uploads/Small/", "");
                                       _imagePath = attribValue;
                                   }
                                   //else if (_imageVar == "")
                                   //{
                                   //    categoryAttribute.FileValue = _imageVar;
                                   //}
                                   else
                                   {
                                       _imagePath = attribValue;
                                   }
                               }
                               else
                               {
                                   _imagePath = strArray[strArray.Length - 1];
                               }
                           }
                           else
                           {
                               _imagePath = attribValue;
                           }
                       }
                       imageCounterFirst++;
                       if (toInsertIntoDB)
                       {
                           if (_attributeID == 12)
                           {
                               categoryInfo.CategoryBaseImage = _imagePath;
                           }
                           else if (_attributeID == 21)
                           {
                               categoryInfo.CategoryThumbnailImage = _imagePath;
                           }
                           else if (_attributeID == 22)
                           {
                               categoryInfo.CategorySmallImage = _imagePath;
                           }
                           //listCategoryAttributes.Add(categoryAttribute);
                       }
                   }
                   else if (categoryAttribute.AttributeID > 43)
                   {
                       if (categoryInfo.HasSystemAttribute)
                       {
                           categoryInfo.HasSystemAttribute = false;
                       }
                       if (inputTypeID == 1)
                       {
                           if (validationTypeID == 3)
                           {
                               if (formValidation.ValidateValue(attribName, validationTypeID, attribValue))
                               {
                                   categoryAttribute.DecimalValue = decimal.Parse(attribValue);
                               }
                               else
                               {
                                   isFormValid = false;
                                   break;
                               }
                           }
                           else if (validationTypeID == 5)
                           {
                               if (formValidation.ValidateValue(attribName, validationTypeID, attribValue))
                               {
                                   categoryAttribute.IntValue = Int32.Parse(attribValue);
                               }
                               else
                               {
                                   isFormValid = false;
                                   break;
                               }
                           }
                           else
                           {
                               if (formValidation.ValidateValue(attribName, validationTypeID, attribValue))
                               {
                                   categoryAttribute.NvarcharValue = attribValue;
                               }
                               else
                               {
                                   isFormValid = false;
                                   break;
                               }
                           }
                       }
                       else if (inputTypeID == 2)
                       {
                           if (formValidation.ValidateValue(attribName, validationTypeID, attribValue))
                           {
                               categoryAttribute.TextValue = attribValue;
                           }
                           else
                           {
                               isFormValid = false;
                               break;
                           }
                       }
                       else if (inputTypeID == 3)
                       {
                           if (formValidation.ValidateValue(attribName, validationTypeID, attribValue))
                           {
                               if (!string.IsNullOrEmpty(attribValue))
                               {
                                   categoryAttribute.DateValue = DateTime.Parse(attribValue);
                               }
                           }
                           else
                           {
                               isFormValid = false;
                               break;
                           }
                       }
                       else if (inputTypeID == 4)
                       {
                           if (formValidation.ValidateValue(attribName, validationTypeID, attribValue))
                           {
                               if (!string.IsNullOrEmpty(attribValue))
                               {
                                   categoryAttribute.BooleanValue = (attribValue == "1" ||
                                                                     attribValue.ToLower() == "true")
                                                                        ? true
                                                                        : false;
                               }
                               else
                               {
                                   categoryAttribute.BooleanValue = false;
                               }
                           }
                           else
                           {
                               isFormValid = false;
                               break;
                           }
                       }
                       else if (inputTypeID == 5 || inputTypeID == 6 || inputTypeID == 9 || inputTypeID == 10 ||
                                inputTypeID == 11 || inputTypeID == 12)
                       {
                           if (formValidation.ValidateValue(attribName, validationTypeID, attribValue))
                           {
                               categoryAttribute.OptionValues = attribValue;
                           }
                           else
                           {
                               isFormValid = false;
                               break;
                           }
                       }
                       else if (inputTypeID == 7)
                       {
                           if (formValidation.ValidateValue(attribName, validationTypeID, attribValue))
                           {
                               categoryAttribute.DecimalValue = decimal.Parse(attribValue);
                           }
                           else
                           {
                               isFormValid = false;
                               break;
                           }
                       }
                       else if (inputTypeID == 8)
                       {
                           if (imageCounterFirst%2 == 0)
                           {
                               toInsertIntoDB = false;
                               if (!string.IsNullOrEmpty(attribValue) && attribValue.ToLower() != "undefined")
                               {
                                   if (formValidation.ValidateValue(attribName, validationTypeID, attribValue))
                                   {
                                       imageVar = attribValue;
                                   }
                                   else
                                   {
                                       isFormValid = false;
                                       break;
                                   }
                               }
                               else
                               {
                                   imageVar = "";
                               }
                           }
                           else
                           {
                               toInsertIntoDB = true;

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

                                   string tempFolder = @"Upload\temp";
                                   FileHelperController fileObj = new FileHelperController();
                                   attribValue = fileObj.MoveFileToModuleFolder(tempFolder, attribValue, imageVar,
                                                                                categoryObj.LargeThumbNailImageHeight,
                                                                                 categoryObj.LargeThumbNailImageWidth,
                                                                                categoryObj.MediumImageHeight,
                                                                                categoryObj.MediumImageWidth,
                                                                                categoryObj.SmallImageHeight,
                                                                                categoryObj.SmallImageWidth,
                                                                                @"Modules\AspxCommerce\AspxCategoryManagement\uploads\",
                                                                                categoryObj.CategoryId, "cat_");
                                   categoryAttribute.FileValue = attribValue;
                               }
                                   //else if (_imageVar == "")
                                   //{
                                   //    categoryAttribute.FileValue = _imageVar;
                                   //}
                               else
                               {
                                   categoryAttribute.FileValue = attribValue;
                               }
                           }
                           imageCounterFirst++;
                       }
                       if (toInsertIntoDB)
                       {
                           listCategoryAttributes.Add(categoryAttribute);
                       }
                   }
               }
               if (isFormValid)
               {
                   string attributeIDs = "1,2,3,9,10,11,12,16,17,18,19,20,21,22,36";
                   catID = AspxCategoryManageProvider.CategoryAddUpdate(categoryInfo,
                                                                        listCategoryAttributes, aspxCommonObj.UserName,
                                                                        aspxCommonObj.CultureName, attributeIDs);

               }
               else
               {
                   throw new Exception("Form is not valid one");
               }
               return catID;
           }
           catch (Exception e)
           {
               throw e;
           }
       }
        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 static 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 _GroupID = 0;
            bool _isIncludeInPriceRule = false;
            int _displayOrder = 0;

            bool toInsertIntoDB = true;
            bool isFormValid = true;
            string imageVar = string.Empty;
            int imageCounterFirst = 0;
            var formVars = JSONHelper.Deserialise<List<AspxNameValue>>(itemObj.FormVars);
            ItemInformationDetailsInfo itemInfo = new ItemInformationDetailsInfo();
            ItemSetting itemSettings = new ItemSetting();
            itemSettings = itemObj.Settings;
            itemInfo.NewFromDate = "1900/01/01";
            itemInfo.NewToDate = "2999/12/30";
            itemInfo.FeaturedFrom = "1900/01/01";
            itemInfo.FeaturedTo = "2999/12/30";
            itemInfo.SpecialFrom = "1900/01/01";
            itemInfo.SpecialTo = "2999/12/30";
            itemInfo.SpecialPriceFrom = "1900/01/01";
            itemInfo.SpecialPriceTo = "2999/12/30";
            itemInfo.IsManageInventory = itemSettings.IsManageInventory;
            itemInfo.IsUsedStoreSetting = itemSettings.IsUsedStoreSetting;
            itemInfo.MinCartQuantity = itemSettings.MinCartQuantity;
            itemInfo.MaxCartQuantity = itemSettings.MaxCartQuantity;
            itemInfo.LowStockQuantity = itemSettings.LowStockQuantity;
            itemInfo.OutOfStockQuantity = itemSettings.OutOfStockQuantity;

            List<ItemAttributeDetailsInfo> listItemAttributes = new List<ItemAttributeDetailsInfo>();
            bool hasSystemAttributesOnly = true;
            string attributeIDs = "1,2,3,4,5,6,7,8,9,10,11,13,14,15,19,20,23,24,25,26,27,28,29,30,31,32,33,34,44,45,46,47,48";
            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();
                ItemAttributeDetailsInfo itemAttribute = new ItemAttributeDetailsInfo();

                if (jsonVar.Length > 1)
                {
                    _attributeID = Int32.Parse(jsonVar[0]);
                    _inputTypeID = Int32.Parse(jsonVar[1]);
                    _ValidationTypeID = Int32.Parse(jsonVar[2]);
                    _GroupID = Int32.Parse(jsonVar[4]);
                    _isIncludeInPriceRule = bool.Parse(jsonVar[5]);
                    _displayOrder = Int32.Parse(jsonVar[6]);
                    itemAttribute.AttributeID = _attributeID;
                    itemAttribute.InputTypeID = _inputTypeID;
                    itemAttribute.ValidationTypeID = _ValidationTypeID;
                    itemAttribute.GroupID = _GroupID;
                    itemAttribute.IsIncludeInPriceRule = _isIncludeInPriceRule;
                    itemAttribute.DisplayOrder = _displayOrder;
                    if (_attributeID > 48)
                    {
                        if (hasSystemAttributesOnly)
                        {
                            hasSystemAttributesOnly = false;
                        }
                    }

                    if (_attributeID == 4)
                    {
                        itemInfo.SKU = formVars[i].value;
                    }
                    else if (_attributeID == 19)
                    {
                        itemInfo.ActiveFrom = formVars[i].value;
                    }
                    else if (_attributeID == 20)
                    {
                        itemInfo.ActiveTo = formVars[i].value;
                    }
                    else if (_attributeID == 23)
                    {
                        itemInfo.HidePrice = Convert.ToBoolean(formVars[i].value);
                    }
                    else if (_attributeID == 24)
                    {
                        itemInfo.HideInRSSFeed = Convert.ToBoolean(formVars[i].value);
                    }
                    else if (_attributeID == 25)
                    {
                        itemInfo.HideToAnonymous = Convert.ToBoolean(formVars[i].value);
                    }
                    else if (_attributeID == 1)
                    {
                        itemInfo.Name = formVars[i].value;
                    }
                    else if (_attributeID == 2)
                    {
                        itemInfo.Description = formVars[i].value;
                    }
                    else if (_attributeID == 3)
                    {
                        itemInfo.ShortDescription = formVars[i].value;
                    }
                    else if (_attributeID == 5)
                    {
                        itemInfo.Weight = Convert.ToDecimal(formVars[i].value);
                    }
                    else if (_attributeID == 6)
                    {
                        if (formVars[i].value == "" || formVars[i].value == null)
                        {
                            itemInfo.NewFromDate =itemInfo.NewFromDate;
                        }
                        else
                        {
                            itemInfo.NewFromDate = formVars[i].value;
                        }
                    }
                    else if (_attributeID == 7)
                    {
                        if (formVars[i].value == "" || formVars[i].value == null)
                        {
                            itemInfo.NewToDate = itemInfo.NewToDate;
                        }
                        else
                        {
                            itemInfo.NewToDate = formVars[i].value;
                        }
                    }
                    else if (_attributeID == 8)
                    {
                        itemInfo.Price = Convert.ToDecimal(formVars[i].value);
                    }
                    else if (_attributeID == 9)
                    {
                        itemInfo.MetaTitle = formVars[i].value;
                    }
                    else if (_attributeID == 10)
                    {
                        itemInfo.MetaKeyword = formVars[i].value;
                    }
                    else if (_attributeID == 11)
                    {
                        itemInfo.MetaDescription = formVars[i].value;
                    }
                    else if (_attributeID == 13 && formVars[i].value != "")
                    {
                        itemInfo.ListPrice = Convert.ToDecimal(formVars[i].value);
                    }
                    else if (_attributeID == 14)
                    {
                        itemInfo.VisibilityOptionValueID = Convert.ToInt32(formVars[i].value);
                    }
                    else if (_attributeID == 15)
                    {
                        itemInfo.Quantity = Convert.ToInt32(formVars[i].value);
                    }
                    else if (_attributeID == 26)
                    {
                        itemInfo.IsFeaturedOptionValueID = Convert.ToInt32(formVars[i].value);
                    }
                    else if (_attributeID == 27)
                    {
                        if (formVars[i].value == "" || formVars[i].value == null)
                        {
                            itemInfo.FeaturedFrom = itemInfo.FeaturedFrom;
                        }
                        else
                        {
                            itemInfo.FeaturedFrom = formVars[i].value;
                        }                      
                    }
                    else if (_attributeID == 28)
                    {
                        if (formVars[i].value == "" || formVars[i].value == null)
                        {
                            itemInfo.FeaturedTo = itemInfo.FeaturedTo;
                        }
                        else
                        {
                            itemInfo.FeaturedTo = formVars[i].value;
                        }                        
                    }
                    else if (_attributeID == 29)
                    {
                        itemInfo.IsSpecialOptionValueID = Convert.ToInt32(formVars[i].value);
                    }
                    else if (_attributeID == 30)
                    {
                        if (formVars[i].value == "" || formVars[i].value == null)
                        {
                            itemInfo.SpecialFrom = itemInfo.SpecialFrom;
                        }
                        else
                        {
                            itemInfo.SpecialFrom = formVars[i].value;
                        }                     
                    }
                    else if (_attributeID == 31)
                    {
                        if (formVars[i].value == "" || formVars[i].value == null)
                        {
                            itemInfo.SpecialTo = itemInfo.SpecialTo;
                        }
                        else
                        {
                            itemInfo.SpecialTo = formVars[i].value;
                        }                            
                    }
                    else if (_attributeID == 32 && formVars[i].value != "")
                    {
                        itemInfo.Length = Convert.ToDecimal(formVars[i].value);
                    }
                    else if (_attributeID == 33 && formVars[i].value != "")
                    {
                        itemInfo.Height = Convert.ToDecimal(formVars[i].value);
                    }
                    else if (_attributeID == 34 && formVars[i].value != "")
                    {
                        itemInfo.Width = Convert.ToDecimal(formVars[i].value);
                    }
                    else if (_attributeID == 35)
                    {
                        itemInfo.IsPromo = Convert.ToInt32(formVars[i].value);
                    }
                    else if (_attributeID == 37)
                    {
                        itemInfo.ServiceDuration = Convert.ToInt32(formVars[i].value);
                    }
                    else if (_attributeID == 44 && formVars[i].value != "")
                    {
                        itemInfo.CostPrice = Convert.ToDecimal(formVars[i].value);
                    }
                    else if (_attributeID == 45 && formVars[i].value != "")
                    {
                        itemInfo.SpecialPrice = Convert.ToDecimal(formVars[i].value);
                    }
                    else if (_attributeID == 46)
                    {
                        if (formVars[i].value == "" || formVars[i].value == null)
                        {
                            itemInfo.SpecialPriceFrom = itemInfo.SpecialPriceFrom;
                        }
                        else
                        {
                            itemInfo.SpecialPriceFrom = formVars[i].value;
                        }                         
                    }
                    else if (_attributeID == 47)
                    {
                        if (formVars[i].value == "" || formVars[i].value == null)
                        {
                            itemInfo.SpecialPriceTo = itemInfo.SpecialPriceTo;
                        }
                        else
                        {
                            itemInfo.SpecialPriceTo = formVars[i].value;
                        }                         
                    }
                    else if (_attributeID == 48 && formVars[i].value != "")
                    {
                        itemInfo.ManufacturerPrice = Convert.ToDecimal(formVars[i].value);
                    }

                }

                if (_attributeID == 37)
                {
                    if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                    {
                        itemAttribute.IntValue = int.Parse(formVars[i].value);
                        listItemAttributes.Add(itemAttribute);
                    }
                    else
                    {
                        isFormValid = false;
                        break;
                    }
                }
                else if (_attributeID == 35)
                {
                    if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                    {
                        itemAttribute.OptionValues = formVars[i].value;
                        listItemAttributes.Add(itemAttribute);
                    }
                    else
                    {
                        isFormValid = false;
                        break;
                    }
                }

                if (_attributeID > 48)
                {
                    if (_inputTypeID == 1)
                    {
                        if (_ValidationTypeID == 3)
                        {
                            if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                            {
                                itemAttribute.DecimalValue = decimal.Parse(formVars[i].value);
                            }
                            else
                            {
                                isFormValid = false;
                                break;
                            }
                        }
                        else if (_ValidationTypeID == 5)
                        {
                            if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                            {
                                itemAttribute.IntValue = int.Parse(formVars[i].value);
                            }
                            else
                            {
                                isFormValid = false;
                                break;
                            }
                        }
                        else
                        {
                            if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                            {
                                itemAttribute.NvarcharValue = formVars[i].value;
                            }
                            else
                            {
                                isFormValid = false;
                                break;
                            }
                        }
                    }
                    else if (_inputTypeID == 2)
                    {
                        if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                        {
                            itemAttribute.TextValue = 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))
                            {
                                itemAttribute.DateValue = DateTime.Parse(formVars[i].value);
                            }
                        }
                        else
                        {
                            isFormValid = false;
                            break;
                        }
                    }
                    else if (_inputTypeID == 4)
                    {
                        if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                        {
                            if (!string.IsNullOrEmpty(attribValue))
                            {
                                itemAttribute.BooleanValue = (formVars[i].value == "1" ||
                                                              formVars[i].value.ToLower() == "true")
                                                                 ? true
                                                                 : false;
                            }
                            else
                            {
                                itemAttribute.BooleanValue = false;
                            }
                        }
                        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))
                        {
                            itemAttribute.OptionValues = formVars[i].value;
                        }
                        else
                        {
                            isFormValid = false;
                            break;
                        }
                    }
                    else if (_inputTypeID == 7)
                    {
                        if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                        {
                            itemAttribute.DecimalValue = decimal.Parse(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_");
                                itemAttribute.FileValue =
                                    attribValue.Replace(@"Modules\AspxCommerce\AspxItemsManagement\uploads\", " ");
                            }
                            else
                            {
                                itemAttribute.FileValue =
                                    attribValue.Replace(@"Modules\AspxCommerce\AspxItemsManagement\uploads\", " ");
                            }
                        }
                        imageCounterFirst++;
                    }
                    if (toInsertIntoDB)
                    {
                        listItemAttributes.Add(itemAttribute);
                    }
                }
            }
            if (isFormValid)
            {
                string groupPrices = GetItemGroupPriceInString(itemObj.GroupPrice, itemObj.ItemId);
                itemObj.ItemId = AspxItemMgntProvider.SaveUpdateItemAttributes(itemObj, aspxCommonObj, true,
                                                                               isModified, itemInfo,
                                                                               listItemAttributes, attributeIDs,
                                                                               hasSystemAttributesOnly, updateFlag, groupPrices);
            }
            else
            {
                throw new Exception("Form is not valid one");
            }

            return itemObj.ItemId;
        }
        public static 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  _GroupID              = 0;
            bool _isIncludeInPriceRule = false;
            int  _displayOrder         = 0;

            bool   toInsertIntoDB               = true;
            bool   isFormValid                  = true;
            string imageVar                     = string.Empty;
            int    imageCounterFirst            = 0;
            var    formVars                     = JSONHelper.Deserialise <List <AspxNameValue> >(itemObj.FormVars);
            ItemInformationDetailsInfo itemInfo = new ItemInformationDetailsInfo();

            itemInfo.NewFromDate  = "1900/01/01";
            itemInfo.NewToDate    = "2999/12/30";
            itemInfo.FeaturedFrom = "1900/01/01";
            itemInfo.FeaturedTo   = "2999/12/30";
            itemInfo.SpecialFrom  = "1900/01/01";
            itemInfo.SpecialTo    = "2999/12/30";
            List <ItemAttributeDetailsInfo> listItemAttributes = new List <ItemAttributeDetailsInfo>();
            bool   hasSystemAttributesOnly = true;
            string attributeIDs            = "1,2,3,4,5,6,7,8,9,10,11,13,14,15,19,20,23,24,25,26,27,28,29,30,31,32,33,34";

            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();
                ItemAttributeDetailsInfo itemAttribute  = new ItemAttributeDetailsInfo();

                if (jsonVar.Length > 1)
                {
                    _attributeID                       = Int32.Parse(jsonVar[0]);
                    _inputTypeID                       = Int32.Parse(jsonVar[1]);
                    _ValidationTypeID                  = Int32.Parse(jsonVar[2]);
                    _GroupID                           = Int32.Parse(jsonVar[4]);
                    _isIncludeInPriceRule              = bool.Parse(jsonVar[5]);
                    _displayOrder                      = Int32.Parse(jsonVar[6]);
                    itemAttribute.AttributeID          = _attributeID;
                    itemAttribute.InputTypeID          = _inputTypeID;
                    itemAttribute.ValidationTypeID     = _ValidationTypeID;
                    itemAttribute.GroupID              = _GroupID;
                    itemAttribute.IsIncludeInPriceRule = _isIncludeInPriceRule;
                    itemAttribute.DisplayOrder         = _displayOrder;
                    if (_attributeID > 43)
                    {
                        if (hasSystemAttributesOnly)
                        {
                            hasSystemAttributesOnly = false;
                        }
                    }

                    if (_attributeID == 4)
                    {
                        itemInfo.SKU = formVars[i].value;
                    }
                    else if (_attributeID == 19)
                    {
                        itemInfo.ActiveFrom = formVars[i].value;
                    }
                    else if (_attributeID == 20)
                    {
                        itemInfo.ActiveTo = formVars[i].value;
                    }
                    else if (_attributeID == 23)
                    {
                        itemInfo.HidePrice = Convert.ToBoolean(formVars[i].value);
                    }
                    else if (_attributeID == 24)
                    {
                        itemInfo.HideInRSSFeed = Convert.ToBoolean(formVars[i].value);
                    }
                    else if (_attributeID == 25)
                    {
                        itemInfo.HideToAnonymous = Convert.ToBoolean(formVars[i].value);
                    }
                    else if (_attributeID == 1)
                    {
                        itemInfo.Name = formVars[i].value;
                    }
                    else if (_attributeID == 2)
                    {
                        itemInfo.Description = formVars[i].value;
                    }
                    else if (_attributeID == 3)
                    {
                        itemInfo.ShortDescription = formVars[i].value;
                    }
                    else if (_attributeID == 5)
                    {
                        itemInfo.Weight = Convert.ToDecimal(formVars[i].value);
                    }
                    else if (_attributeID == 6)
                    {
                        itemInfo.NewFromDate = formVars[i].value;
                    }
                    else if (_attributeID == 7)
                    {
                        itemInfo.NewToDate = formVars[i].value;
                    }
                    else if (_attributeID == 8)
                    {
                        itemInfo.Price = Convert.ToDecimal(formVars[i].value);
                    }
                    else if (_attributeID == 9)
                    {
                        itemInfo.MetaTitle = formVars[i].value;
                    }
                    else if (_attributeID == 10)
                    {
                        itemInfo.MetaKeyword = formVars[i].value;
                    }
                    else if (_attributeID == 11)
                    {
                        itemInfo.MetaDescription = formVars[i].value;
                    }
                    else if (_attributeID == 13 && formVars[i].value != "")
                    {
                        itemInfo.ListPrice = Convert.ToDecimal(formVars[i].value);
                    }
                    else if (_attributeID == 14)
                    {
                        itemInfo.VisibilityOptionValueID = Convert.ToInt32(formVars[i].value);
                    }
                    else if (_attributeID == 15)
                    {
                        itemInfo.Quantity = Convert.ToInt32(formVars[i].value);
                    }
                    else if (_attributeID == 26)
                    {
                        itemInfo.IsFeaturedOptionValueID = Convert.ToInt32(formVars[i].value);
                    }
                    else if (_attributeID == 27)
                    {
                        itemInfo.FeaturedFrom = formVars[i].value;
                    }
                    else if (_attributeID == 28)
                    {
                        itemInfo.FeaturedTo = formVars[i].value;
                    }
                    else if (_attributeID == 29)
                    {
                        itemInfo.IsSpecialOptionValueID = Convert.ToInt32(formVars[i].value);
                    }
                    else if (_attributeID == 30)
                    {
                        itemInfo.SpecialFrom = formVars[i].value;
                    }
                    else if (_attributeID == 31)
                    {
                        itemInfo.SpecialTo = formVars[i].value;
                    }
                    else if (_attributeID == 32)
                    {
                        itemInfo.Length = Convert.ToDecimal(formVars[i].value);
                    }
                    else if (_attributeID == 33)
                    {
                        itemInfo.Height = Convert.ToDecimal(formVars[i].value);
                    }
                    else if (_attributeID == 34)
                    {
                        itemInfo.Width = Convert.ToDecimal(formVars[i].value);
                    }
                    else if (_attributeID == 35)
                    {
                        itemInfo.IsPromo = Convert.ToInt32(formVars[i].value);
                    }
                    else if (_attributeID == 37)
                    {
                        itemInfo.ServiceDuration = Convert.ToInt32(formVars[i].value);
                    }
                }

                if (_attributeID == 37)
                {
                    if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                    {
                        itemAttribute.IntValue = int.Parse(formVars[i].value);
                        listItemAttributes.Add(itemAttribute);
                    }
                    else
                    {
                        isFormValid = false;
                        break;
                    }
                }
                else if (_attributeID == 35)
                {
                    if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                    {
                        itemAttribute.OptionValues = formVars[i].value;
                        listItemAttributes.Add(itemAttribute);
                    }
                    else
                    {
                        isFormValid = false;
                        break;
                    }
                }

                if (_attributeID > 43)
                {
                    if (_inputTypeID == 1)
                    {
                        if (_ValidationTypeID == 3)
                        {
                            if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                            {
                                itemAttribute.DecimalValue = decimal.Parse(formVars[i].value);
                            }
                            else
                            {
                                isFormValid = false;
                                break;
                            }
                        }
                        else if (_ValidationTypeID == 5)
                        {
                            if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                            {
                                itemAttribute.IntValue = int.Parse(formVars[i].value);
                            }
                            else
                            {
                                isFormValid = false;
                                break;
                            }
                        }
                        else
                        {
                            if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                            {
                                itemAttribute.NvarcharValue = formVars[i].value;
                            }
                            else
                            {
                                isFormValid = false;
                                break;
                            }
                        }
                    }
                    else if (_inputTypeID == 2)
                    {
                        if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                        {
                            itemAttribute.TextValue = 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))
                            {
                                itemAttribute.DateValue = DateTime.Parse(formVars[i].value);
                            }
                        }
                        else
                        {
                            isFormValid = false;
                            break;
                        }
                    }
                    else if (_inputTypeID == 4)
                    {
                        if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                        {
                            if (!string.IsNullOrEmpty(attribValue))
                            {
                                itemAttribute.BooleanValue = (formVars[i].value == "1" ||
                                                              formVars[i].value.ToLower() == "true")
                                                                 ? true
                                                                 : false;
                            }
                            else
                            {
                                itemAttribute.BooleanValue = false;
                            }
                        }
                        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))
                        {
                            itemAttribute.OptionValues = formVars[i].value;
                        }
                        else
                        {
                            isFormValid = false;
                            break;
                        }
                    }
                    else if (_inputTypeID == 7)
                    {
                        if (formValidation.ValidateValue(formVars[i].name, _ValidationTypeID, formVars[i].value))
                        {
                            itemAttribute.DecimalValue = decimal.Parse(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_");
                                itemAttribute.FileValue =
                                    attribValue.Replace(@"Modules\AspxCommerce\AspxItemsManagement\uploads\", " ");
                            }
                            else
                            {
                                itemAttribute.FileValue =
                                    attribValue.Replace(@"Modules\AspxCommerce\AspxItemsManagement\uploads\", " ");
                            }
                        }
                        imageCounterFirst++;
                    }
                    if (toInsertIntoDB)
                    {
                        listItemAttributes.Add(itemAttribute);
                    }
                }
            }
            if (isFormValid)
            {
                itemObj.ItemId = AspxItemMgntProvider.SaveUpdateItemAttributes(itemObj, aspxCommonObj, true,
                                                                               isModified, itemInfo,
                                                                               listItemAttributes, attributeIDs,
                                                                               hasSystemAttributesOnly, updateFlag);
            }
            else
            {
                throw new Exception("Form is not valid one");
            }

            return(itemObj.ItemId);
        }