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 string SaveCategory(CategoryInfo.CategorySaveBasicInfo categoryObj, AspxCommonInfo aspxCommonObj)
 {
     try
     {
         int categoryId = AspxCategoryManageController.SaveCategory(categoryObj, aspxCommonObj);
         CacheHelper.Clear("CategoryInfo" + aspxCommonObj.StoreID + aspxCommonObj.PortalID + "_" + aspxCommonObj.CultureName);
         CacheHelper.Clear("CategoryForSearch" + aspxCommonObj.StoreID + aspxCommonObj.PortalID + "_" + aspxCommonObj.CultureName);
         if (categoryObj.ParentId > 0)
         {
             return
                 "({\"returnStatus\":1,\"Message\":\"Sub category has been saved successfully.\",\"categoryID\":" +
                 categoryId + "})";
         }
         else
         {
             return "({\"returnStatus\":1,\"Message\":\"Category has been saved successfully.\",\"categoryID\":" +
                    categoryId + "})";
         }
     }
     catch (Exception e)
     {
         ErrorHandler errHandler = new ErrorHandler();
         if (errHandler.LogWCFException(e))
         {
             return "({\"returnStatus\":-1,\"errorMessage\":'" + e.Message + "'})";
         }
         else
         {
             return "({\"returnStatus\":-1,\"errorMessage\":\"Error while saving category!\"})";
         }
     }
 }
        public int CategoryAddUpdate(CategoryInfo categoryInfo,string selectedItems, List<CategoryAttributeInfo> listCA, string userName, string culture)
        {
            SQLHandler sqlHandler = new SQLHandler();
            int categoryID = 0;
            List<KeyValuePair<string, object>> parameterCollection = new List<KeyValuePair<string, object>>();
            parameterCollection.Add(new KeyValuePair<string, object>("@CategoryID", categoryInfo.CategoryID));
            parameterCollection.Add(new KeyValuePair<string, object>("@SelectedItems", selectedItems));
            parameterCollection.Add(new KeyValuePair<string, object>("@ParentID", categoryInfo.ParentID));
            parameterCollection.Add(new KeyValuePair<string, object>("@IsShowInSearch", categoryInfo.IsShowInSearch));
            parameterCollection.Add(new KeyValuePair<string, object>("@IsShowInCatalog", categoryInfo.IsShowInCatalog));
            parameterCollection.Add(new KeyValuePair<string, object>("@IsShowInMenu", categoryInfo.IsShowInMenu));
            parameterCollection.Add(new KeyValuePair<string, object>("@ActiveFrom", categoryInfo.ActiveFrom));
            parameterCollection.Add(new KeyValuePair<string, object>("@ActiveTo", categoryInfo.ActiveTo));
            parameterCollection.Add(new KeyValuePair<string, object>("@StoreID", categoryInfo.StoreID));
            parameterCollection.Add(new KeyValuePair<string, object>("@PortalID", categoryInfo.PortalID));
            parameterCollection.Add(new KeyValuePair<string, object>("@IsActive", true));
            parameterCollection.Add(new KeyValuePair<string, object>("@UserName", userName));
            parameterCollection.Add(new KeyValuePair<string, object>("@CultureName", culture));
            try
            {
                categoryID = sqlHandler.ExecuteNonQueryAsGivenType<int>("dbo.usp_Aspx_CategoryAddUpdate", parameterCollection, "@NewCategoryID");
               
                int inputTypeID;
                int validationTypeID;
                string valueType = string.Empty;
                foreach (CategoryAttributeInfo ca in listCA)
                {
                    parameterCollection.Clear();
                    inputTypeID = ca.InputTypeID;
                    validationTypeID = ca.ValidationTypeID;
                    if (inputTypeID == 1)
                    {
                        if (validationTypeID == 3)
                        {
                            parameterCollection.Add(new KeyValuePair<string, object>("@AttributeValue", ca.DecimalValue));
                            valueType = "DECIMAL";
                        }
                        else if (validationTypeID == 5)
                        {
                            parameterCollection.Add(new KeyValuePair<string, object>("@AttributeValue", ca.IntValue));
                            valueType = "INT";
                        }
                        else
                        {
                            parameterCollection.Add(new KeyValuePair<string, object>("@AttributeValue", ca.NvarcharValue));
                            valueType = "NVARCHAR";
                        }
                    }
                    else if (inputTypeID == 2)
                    {
                        parameterCollection.Add(new KeyValuePair<string, object>("@AttributeValue", ca.TextValue));
                        valueType = "TEXT";
                    }
                    else if (inputTypeID == 3)
                    {
                        parameterCollection.Add(new KeyValuePair<string, object>("@AttributeValue", ca.DateValue));
                        valueType = "DATE";
                    }
                    else if (inputTypeID == 4)
                    {
                        parameterCollection.Add(new KeyValuePair<string, object>("@AttributeValue", ca.BooleanValue));
                        valueType = "Boolean";
                    }
                    else if (inputTypeID == 5 || inputTypeID == 6 || inputTypeID == 9 || inputTypeID == 10 || inputTypeID == 11 || inputTypeID == 12)
                    {
                        parameterCollection.Add(new KeyValuePair<string, object>("@AttributeValue", ca.OptionValues));
                        valueType = "OPTIONS";
                    }
                    else if (inputTypeID == 7)
                    {
                        parameterCollection.Add(new KeyValuePair<string, object>("@AttributeValue", ca.DecimalValue));
                        valueType = "DECIMAL";
                    }
                    else if (inputTypeID == 8)
                    {
                        parameterCollection.Add(new KeyValuePair<string, object>("@AttributeValue", ca.FileValue));
                        valueType = "FILE";
                    }
                    parameterCollection.Add(new KeyValuePair<string, object>("@CategoryID", categoryID));
                    parameterCollection.Add(new KeyValuePair<string, object>("@AttributeID", ca.AttributeID));
                    parameterCollection.Add(new KeyValuePair<string, object>("@StoreID", categoryInfo.StoreID));
                    parameterCollection.Add(new KeyValuePair<string, object>("@PortalID", categoryInfo.PortalID));
                    parameterCollection.Add(new KeyValuePair<string, object>("@UserName", userName));
                    parameterCollection.Add(new KeyValuePair<string, object>("@CultureName", culture));
                    sqlHandler.ExecuteNonQuery("dbo.usp_Aspx_CategoryAttributesValue" + valueType + "AddUpdate", parameterCollection);
                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
            return categoryID;
        }
       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;
           }
       }
Exemplo n.º 5
0
        public CategoryInfo CategoryAddUpdate(CategoryInfo categoryInfo, string selectedItems, List <CategoryAttributeInfo> listCA, string userName, string culture)
        {
            SQLHandler sqlHandler = new SQLHandler();

            System.Nullable <Int32> categoryID = 0;
            List <KeyValuePair <string, object> > parameterCollection = new List <KeyValuePair <string, object> >();

            parameterCollection.Add(new KeyValuePair <string, object>("@CategoryID", categoryInfo.CategoryID));
            parameterCollection.Add(new KeyValuePair <string, object>("@SelectedItems", selectedItems));
            parameterCollection.Add(new KeyValuePair <string, object>("@ParentID", categoryInfo.ParentID));
            parameterCollection.Add(new KeyValuePair <string, object>("@IsShowInSearch", categoryInfo.IsShowInSearch));
            parameterCollection.Add(new KeyValuePair <string, object>("@IsShowInCatalog", categoryInfo.IsShowInCatalog));
            parameterCollection.Add(new KeyValuePair <string, object>("@IsShowInMenu", categoryInfo.IsShowInMenu));
            parameterCollection.Add(new KeyValuePair <string, object>("@ActiveFrom", categoryInfo.ActiveFrom));
            parameterCollection.Add(new KeyValuePair <string, object>("@ActiveTo", categoryInfo.ActiveTo));
            parameterCollection.Add(new KeyValuePair <string, object>("@StoreID", categoryInfo.StoreID));
            parameterCollection.Add(new KeyValuePair <string, object>("@PortalID", categoryInfo.PortalID));
            parameterCollection.Add(new KeyValuePair <string, object>("@IsActive", true));
            parameterCollection.Add(new KeyValuePair <string, object>("@Username", userName));
            parameterCollection.Add(new KeyValuePair <string, object>("@CultureName", culture));
            try
            {
                categoryID = sqlHandler.ExecuteNonQueryAsGivenType <int>("dbo.usp_Aspx_CategoryAddUpdate", parameterCollection, "@NewCategoryID");

                int    inputTypeID;
                int    validationTypeID;
                string valueType = string.Empty;
                foreach (CategoryAttributeInfo ca in listCA)
                {
                    parameterCollection.Clear();
                    inputTypeID      = ca.InputTypeID;
                    validationTypeID = ca.ValidationTypeID;
                    if (inputTypeID == 1)
                    {
                        if (validationTypeID == 3)
                        {
                            parameterCollection.Add(new KeyValuePair <string, object>("@AttributeValue", ca.DecimalValue));
                            valueType = "DECIMAL";
                        }
                        else if (validationTypeID == 5)
                        {
                            parameterCollection.Add(new KeyValuePair <string, object>("@AttributeValue", ca.IntValue));
                            valueType = "INT";
                        }
                        else
                        {
                            parameterCollection.Add(new KeyValuePair <string, object>("@AttributeValue", ca.NvarcharValue));
                            valueType = "NVARCHAR";
                        }
                    }
                    else if (inputTypeID == 2)
                    {
                        parameterCollection.Add(new KeyValuePair <string, object>("@AttributeValue", ca.TextValue));
                        valueType = "TEXT";
                    }
                    else if (inputTypeID == 3)
                    {
                        parameterCollection.Add(new KeyValuePair <string, object>("@AttributeValue", ca.DateValue));
                        valueType = "DATE";
                    }
                    else if (inputTypeID == 4)
                    {
                        parameterCollection.Add(new KeyValuePair <string, object>("@AttributeValue", ca.BooleanValue));
                        valueType = "Boolean";
                    }
                    else if (inputTypeID == 5 || inputTypeID == 6 || inputTypeID == 9 || inputTypeID == 10 || inputTypeID == 11 || inputTypeID == 12)
                    {
                        parameterCollection.Add(new KeyValuePair <string, object>("@AttributeValue", ca.OptionValues));
                        valueType = "OPTIONS";
                    }
                    else if (inputTypeID == 7)
                    {
                        parameterCollection.Add(new KeyValuePair <string, object>("@AttributeValue", ca.DecimalValue));
                        valueType = "DECIMAL";
                    }
                    else if (inputTypeID == 8)
                    {
                        parameterCollection.Add(new KeyValuePair <string, object>("@AttributeValue", ca.FileValue));
                        valueType = "FILE";
                    }
                    parameterCollection.Add(new KeyValuePair <string, object>("@CategoryID", categoryID));
                    parameterCollection.Add(new KeyValuePair <string, object>("@AttributeID", ca.AttributeID));
                    parameterCollection.Add(new KeyValuePair <string, object>("@StoreID", categoryInfo.StoreID));
                    parameterCollection.Add(new KeyValuePair <string, object>("@PortalID", categoryInfo.PortalID));
                    parameterCollection.Add(new KeyValuePair <string, object>("@Username", userName));
                    parameterCollection.Add(new KeyValuePair <string, object>("@CultureName", culture));
                    sqlHandler.ExecuteNonQuery("dbo.usp_Aspx_CategoryAttributesValue" + valueType + "AddUpdate", parameterCollection);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(categoryInfo);
        }
Exemplo n.º 6
0
        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 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;
            }
        }
Exemplo n.º 8
0
        public static int CategoryAddUpdate(CategoryInfo categoryInfo, List <CategoryAttributeInfo> listCA, string userName, string culture, string attributeIDs)
        {
            OracleHandler sqlHandler = new OracleHandler();
            int           categoryID = 0;
            List <KeyValuePair <string, object> > parameterCollection = new List <KeyValuePair <string, object> >();

            parameterCollection.Add(new KeyValuePair <string, object>("CategoryID", categoryInfo.CategoryID));
            parameterCollection.Add(new KeyValuePair <string, object>("SelectedItems", categoryInfo.SelectedItems));
            parameterCollection.Add(new KeyValuePair <string, object>("ParentID", categoryInfo.ParentID));
            parameterCollection.Add(new KeyValuePair <string, object>("IsShowInSearch", categoryInfo.IsShowInSearch));
            parameterCollection.Add(new KeyValuePair <string, object>("IsShowInCatalog", categoryInfo.IsShowInCatalog));
            parameterCollection.Add(new KeyValuePair <string, object>("IsShowInMenu", categoryInfo.IsShowInMenu));
            parameterCollection.Add(new KeyValuePair <string, object>("ActiveFrom", categoryInfo.ActiveFrom));
            parameterCollection.Add(new KeyValuePair <string, object>("ActiveTo", categoryInfo.ActiveTo));
            parameterCollection.Add(new KeyValuePair <string, object>("IsService", categoryInfo.IsService));
            parameterCollection.Add(new KeyValuePair <string, object>("BaseImage", categoryInfo.CategoryBaseImage));
            parameterCollection.Add(new KeyValuePair <string, object>("ThumbNailImage", categoryInfo.CategoryThumbnailImage));
            parameterCollection.Add(new KeyValuePair <string, object>("SmallImage", categoryInfo.CategorySmallImage));
            parameterCollection.Add(new KeyValuePair <string, object>("StoreID", categoryInfo.StoreID));
            parameterCollection.Add(new KeyValuePair <string, object>("PortalID", categoryInfo.PortalID));
            parameterCollection.Add(new KeyValuePair <string, object>("IsActive", true));
            parameterCollection.Add(new KeyValuePair <string, object>("UserName", userName));
            parameterCollection.Add(new KeyValuePair <string, object>("CultureName", culture));
            parameterCollection.Add(new KeyValuePair <string, object>("CategoryName", categoryInfo.CategoryName));
            parameterCollection.Add(new KeyValuePair <string, object>("MetaTitle", categoryInfo.MetaTitle));
            parameterCollection.Add(new KeyValuePair <string, object>("Description", categoryInfo.Description));
            parameterCollection.Add(new KeyValuePair <string, object>("ShortDescription", categoryInfo.ShortDescription));
            parameterCollection.Add(new KeyValuePair <string, object>("MetaKeyword", categoryInfo.MetaKeyword));
            parameterCollection.Add(new KeyValuePair <string, object>("MetaDescription", categoryInfo.MetaDescription));
            parameterCollection.Add(new KeyValuePair <string, object>("AttributeIDs", attributeIDs));
            try
            {
                categoryID = sqlHandler.ExecuteNonQueryAsGivenType <int>("usp_Aspx_CategoryAddUpdate", parameterCollection, "NewCategoryID");
                if (!categoryInfo.HasSystemAttribute)
                {
                    int    inputTypeID, validationTypeID;
                    string valueType = string.Empty;
                    foreach (CategoryAttributeInfo ca in listCA)
                    {
                        parameterCollection.Clear();
                        inputTypeID      = ca.InputTypeID;
                        validationTypeID = ca.ValidationTypeID;
                        if (inputTypeID == 1)
                        {
                            if (validationTypeID == 3)
                            {
                                parameterCollection.Add(new KeyValuePair <string, object>("AttributeValue", ca.DecimalValue));
                                valueType = "DECIMAL";
                            }
                            else if (validationTypeID == 5)
                            {
                                parameterCollection.Add(new KeyValuePair <string, object>("AttributeValue", ca.IntValue));
                                valueType = "INT";
                            }
                            else
                            {
                                parameterCollection.Add(new KeyValuePair <string, object>("AttributeValue", ca.NvarcharValue));
                                valueType = "VARCHAR2";
                            }
                        }
                        else if (inputTypeID == 2)
                        {
                            parameterCollection.Add(new KeyValuePair <string, object>("AttributeValue", ca.TextValue));
                            valueType = "TEXT";
                        }
                        else if (inputTypeID == 3)
                        {
                            parameterCollection.Add(new KeyValuePair <string, object>("AttributeValue", ca.DateValue));
                            valueType = "DATE";
                        }
                        else if (inputTypeID == 4)
                        {
                            parameterCollection.Add(new KeyValuePair <string, object>("AttributeValue", ca.BooleanValue));
                            valueType = "Boolean";
                        }
                        else if (inputTypeID == 5 || inputTypeID == 6 || inputTypeID == 9 || inputTypeID == 10 || inputTypeID == 11 || inputTypeID == 12)
                        {
                            parameterCollection.Add(new KeyValuePair <string, object>("AttributeValue", ca.OptionValues));
                            valueType = "OPTIONS";
                        }
                        else if (inputTypeID == 7)
                        {
                            parameterCollection.Add(new KeyValuePair <string, object>("AttributeValue", ca.DecimalValue));
                            valueType = "DECIMAL";
                        }
                        else if (inputTypeID == 8)
                        {
                            parameterCollection.Add(new KeyValuePair <string, object>("AttributeValue", ca.FileValue));
                            valueType = "FILE";
                        }
                        parameterCollection.Add(new KeyValuePair <string, object>("CategoryID", categoryID));
                        parameterCollection.Add(new KeyValuePair <string, object>("AttributeID", ca.AttributeID));
                        parameterCollection.Add(new KeyValuePair <string, object>("StoreID", categoryInfo.StoreID));
                        parameterCollection.Add(new KeyValuePair <string, object>("PortalID", categoryInfo.PortalID));
                        parameterCollection.Add(new KeyValuePair <string, object>("UserName", userName));
                        parameterCollection.Add(new KeyValuePair <string, object>("CultureName", culture));
                        sqlHandler.ExecuteNonQuery("usp_Aspx_CategoryAttributesValue" + valueType + "AddUpdate", parameterCollection);
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            return(categoryID);
        }