public string SaveChangesCategoryTree(Int32 storeID, Int32 portalID, string categoryIDs, string userName)
 {
     try
     {
         CategorySqlProvider categorySqlProvider = new CategorySqlProvider();
         categorySqlProvider.SaveChangesCategoryTree(storeID, portalID, categoryIDs, userName);
         return "({ \"returnStatus\" : 1 , \"Message\" : \"Category tree saved successfully.\" })";
     }
     catch (Exception ex)
     {
         ErrorHandler errHandler = new ErrorHandler();
         if (errHandler.LogWCFException(ex))
         {
             return "({ \"returnStatus\" : -1 , \"errorMessage\" : \"" + ex.Message + "\" })";
         }
         else
         {
             return "({ \"returnStatus\" : -1, \"errorMessage\" : \"Error while saving category tree!\" })";
         }
     }
 }
Ejemplo n.º 2
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 string DeleteCategory(Int32 storeID, Int32 portalID, Int32 categoryID, string userName, string culture)
 {
     try
     {
         CategorySqlProvider categorySqlProvider = new CategorySqlProvider();
         categorySqlProvider.DeleteCategory(storeID, portalID, categoryID, userName, culture);
         return "({ \"returnStatus\" : 1 , \"Message\" : \"Category has been deleted successfully.\" })";
     }
     catch (Exception ex)
     {
         ErrorHandler errHandler = new ErrorHandler();
         if (errHandler.LogWCFException(ex))
         {
             return "({ \"returnStatus\" : -1 , \"errorMessage\" : \"" + ex.Message + "\" })";
         }
         else
         {
             return "({ \"returnStatus\" : -1, \"errorMessage\" : \"Error while deleting category!\" })";
         }
     }
 }
 public List<CategoryItemInfo> GetCategoryItems(Int32 offset, Int32 limit, Int32 categoryID, string sku, string name, System.Nullable<decimal> priceFrom, System.Nullable<decimal> priceTo, Int32 storeID, Int32 portalID, string userName, string culture)
 {
     try
     {
         List<CategoryItemInfo> listCategoryItem;
         CategorySqlProvider categorySqlProvider = new CategorySqlProvider();
         listCategoryItem = categorySqlProvider.GetCategoryItems(offset, limit, categoryID, sku, name, priceFrom, priceTo, storeID, portalID, userName, culture);
         return listCategoryItem;
     }
     catch (Exception ex)
     {
         ErrorHandler errHandler = new ErrorHandler();
         errHandler.LogWCFException(ex);
         throw ex;
     }
 }
 public List<CategoryAttributeInfo> GetCategoryByCategoryID(Int32 categoryID, Int32 storeID, Int32 portalID, string userName, string culture)
 {
     CategorySqlProvider categorySqlProvider = new CategorySqlProvider();
     List<CategoryAttributeInfo> catList = categorySqlProvider.GetCategoryByCategoryID(categoryID, storeID, portalID, userName, culture);
     return catList;
 }
 public List<CategoryInfo> GetCategoryAll(bool isActive, Int32 storeID, Int32 portalID, string userName, string culture)
 {
     try
     {
         CategorySqlProvider categorySqlProvider = new CategorySqlProvider();
         List<CategoryInfo> catList = categorySqlProvider.GetCategoryAll(isActive, storeID, portalID, userName, culture);
         return catList;
     }
     catch (Exception ex)
     {
         ErrorHandler errHandler = new ErrorHandler();
         errHandler.LogWCFException(ex);
         throw ex;
     }
 }
 public List<AttributeFormInfo> GetCategoryFormAttributes(Int32 categoryID, Int32 portalID, Int32 storeID, string userName, string culture)
 {
     try
     {
         CategorySqlProvider categorySqlProvider = new CategorySqlProvider();
         List<AttributeFormInfo> frmFieldList = categorySqlProvider.GetCategoryFormAttributes(categoryID, portalID, storeID, userName, culture);
         return frmFieldList;
     }
     catch (Exception ex)
     {
         ErrorHandler errHandler = new ErrorHandler();
         errHandler.LogWCFException(ex);
         throw ex;
     }
 }
 public bool CheckUniqueCategoryName(string catName, int catId, int storeId, int portalId, string cultureName)
 {
     try
     {
         CategorySqlProvider obj = new CategorySqlProvider();
         return obj.CheckUniqueName(catName, catId, storeId, portalId, cultureName);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 9
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;
            }
        }