public CartPricingRuleInfo GetCartPricingRule(Int32 cartPriceRuleID, Int32 storeID, Int32 portalID, string userName, string culture)
 {
     CartPricingRuleInfo cartPricingRuleInfo = new CartPricingRuleInfo();
     PriceRuleController priceRuleController = new PriceRuleController();
     cartPricingRuleInfo = priceRuleController.GetCartPriceRules(cartPriceRuleID, storeID, portalID, userName, culture);
     return cartPricingRuleInfo;
 }
 public string SaveCartPricingRule(CartPricingRuleInfo objCartPriceRule, Int32 storeID, Int32 portalID, string userName, string culture, object parentID)
 {
     try
     {
         List<KeyValuePair<string, object>> P1 = new List<KeyValuePair<string, object>>();
         //P1.Add(new KeyValuePair<string,object>("@StoreID", storeID));
         P1.Add(new KeyValuePair<string, object>("PortalID", portalID));
         SQLHandler sql = new SQLHandler();
         int count = sql.ExecuteAsScalar<int>("usp_ASPX_CartPrincingRuleCount", P1);
         int maxAllowed = 3;
         int cartPriceRuleId = objCartPriceRule.CartPriceRule.CartPriceRuleID;
         if (cartPriceRuleId > 0)
         {
             maxAllowed++;
         }
         if (count < maxAllowed)
         {
             PriceRuleController priceRuleController = new PriceRuleController();
             priceRuleController.SaveCartPricingRule(objCartPriceRule, storeID, portalID, userName, culture, parentID);
             //return "({ \"returnStatus\" : 1 , \"Message\" : \"Saving cart pricing rule successfully.\" })";
             return "success";
         }
         else
         {
             //return "({ \"returnStatus\" : -1 , \"Message\" : \"No more than 3 rules are allowed in Free version of AspxCommerce!\" })";
             return "notify";
         }
     }
     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 cart pricing rule!\" })";
         }
     }
 }
Example #3
0
        public int SaveCartPricingRule(CartPricingRuleInfo objCartPriceRule, Int32 storeID, Int32 portalID, string userName, string culture, object parentID)
        {
            SQLHandler sqlH = new SQLHandler();
            SqlTransaction tran;
            tran = (SqlTransaction) sqlH.GetTransaction();
            PriceRuleSqlProvider priceRuleSqlProvider = new PriceRuleSqlProvider();
            try
            {
                int cartPriceRuleID = -1;
                cartPriceRuleID = priceRuleSqlProvider.CartPriceRuleAdd(objCartPriceRule.CartPriceRule, tran, portalID,userName, culture);

                priceRuleSqlProvider.RuleConditionAdd(objCartPriceRule.lstRuleCondition,cartPriceRuleID,parentID, tran, portalID, userName,culture);

                foreach (CartPriceRuleRole cartPriceRuleRole in objCartPriceRule.lstCartPriceRuleRoles)
                {
                    cartPriceRuleRole.CartPriceRuleID = cartPriceRuleID;
                    priceRuleSqlProvider.CartPriceRuleRoleAdd(cartPriceRuleRole, tran, portalID, userName,culture);
                }

                foreach (CartPriceRuleStore cartPriceRuleStore in objCartPriceRule.lstCartPriceRuleStores)
                {
                    cartPriceRuleStore.CartPriceRuleID = cartPriceRuleID;
                    priceRuleSqlProvider.CartPriceRuleStoreAdd(cartPriceRuleStore, tran, portalID, userName,culture);
                }
                tran.Commit();
                return cartPriceRuleID;
            }

            catch (SqlException sqlEX)
            {
                tran.Rollback();
                throw new ArgumentException(sqlEX.Message);
            }
            catch (Exception ex)
            {
                tran.Rollback();
                throw ex;
            }
        }
Example #4
0
        public CartPricingRuleInfo GetCartPriceRules(Int32 cartPriceRuleID, Int32 storeID, Int32 portalID, string userName, string culture)
        {
            PriceRuleSqlProvider priceRuleSqlProvider = new PriceRuleSqlProvider();
            CartPricingRuleInfo cartPricingRuleInfo = new CartPricingRuleInfo();

            DataSet ds = new DataSet();
            ds = priceRuleSqlProvider.GetCartPriceRule(cartPriceRuleID, portalID, userName, culture);
            DataTable dtCartPricingRule = ds.Tables[0];
            DataTable dtRuleConditions = ds.Tables[1];
            DataTable dtCartPriceRuleRoles = ds.Tables[2];
            DataTable dtCartPriceRuleStores = ds.Tables[3];

            List<CartPriceRule> lstCartPriceRule = new List<CartPriceRule>();
            lstCartPriceRule = DataSourceHelper.FillCollection<CartPriceRule>(dtCartPricingRule);
            List<RuleCondition> lstRuleConditions = new List<RuleCondition>();
            lstRuleConditions = DataSourceHelper.FillCollection<RuleCondition>(dtRuleConditions);
            List<CartPriceRuleRole> lstCartPriceRuleRole = new List<CartPriceRuleRole>();
            lstCartPriceRuleRole = DataSourceHelper.FillCollection<CartPriceRuleRole>(dtCartPriceRuleRoles);
            List<CartPriceRuleStore> lstCartPriceRuleStore = new List<CartPriceRuleStore>();
            lstCartPriceRuleStore = DataSourceHelper.FillCollection<CartPriceRuleStore>(dtCartPriceRuleStores);

            cartPricingRuleInfo.CartPriceRule = lstCartPriceRule[0];
            List<RuleCondition> lstRC = new List<RuleCondition>();
            foreach (RuleCondition rc in lstRuleConditions)
            {
                RuleCondition objRC = new RuleCondition();
                objRC.ParentID = rc.ParentID;
                objRC.RuleConditionID = rc.RuleConditionID;
                objRC.RuleConditionType = rc.RuleConditionType;
                objRC.CartPriceRuleID = rc.CartPriceRuleID;

                if (rc.RuleConditionType.ToUpper().Trim() == "PAC".ToUpper().Trim())
                {
                    objRC.lstProductAttributeRuleConditions =
                        priceRuleSqlProvider.GetCartPriceProductAttributeConditions(rc.RuleConditionID, portalID);
                    objRC.lstProductAttributeRuleConditions[0].lstCartConditionDetails =
                        priceRuleSqlProvider.GetCartPriceRuleConditionDetails(rc.CartPriceRuleID,rc.RuleConditionID, portalID, userName);
                    lstRC.Add(objRC);
                }
                else if (rc.RuleConditionType.ToUpper().Trim() == "PS".ToUpper().Trim())
                {
                    objRC.lstProductSublectionRuleConditions =
                        priceRuleSqlProvider.GetCartPriceSubSelections(rc.RuleConditionID, portalID);
                    objRC.lstProductSublectionRuleConditions[0].lstCartConditionDetails =
                       priceRuleSqlProvider.GetCartPriceRuleConditionDetails(rc.CartPriceRuleID, rc.RuleConditionID, portalID, userName);
                    lstRC.Add(objRC);

                }
                else if (rc.RuleConditionType.ToUpper().Trim() == "CC".ToUpper().Trim())
                {
                    objRC.lstCartPriceRuleConditions =
                        priceRuleSqlProvider.GetCartPriceRuleConditions(rc.RuleConditionID, portalID);
                    objRC.lstCartPriceRuleConditions[0].lstCartConditionDetails =
                       priceRuleSqlProvider.GetCartPriceRuleConditionDetails(rc.CartPriceRuleID, rc.RuleConditionID, portalID, userName);
                    lstRC.Add(objRC);
                }
            }
            cartPricingRuleInfo.lstRuleCondition = lstRC;
            cartPricingRuleInfo.lstCartPriceRuleRoles = lstCartPriceRuleRole;
            cartPricingRuleInfo.lstCartPriceRuleStores = lstCartPriceRuleStore;

            return cartPricingRuleInfo;
        }
 public string SaveCartPricingRule(CartPricingRuleInfo objCartPriceRule, Int32 storeID, Int32 portalID, string userName, string culture, Array parentID)
 {
     try
     {
         PriceRuleController priceRuleController = new PriceRuleController();
         priceRuleController.SaveCartPricingRule(objCartPriceRule, storeID, portalID, userName, culture, parentID);
         return "({ \"returnStatus\" : 1 , \"Message\" : \"Saving cart pricing rule 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 cart pricing rule!\" })";
         }
     }
 }