Example #1
0
        public async Task AddPolicyRule(Store store, string username, Guid storeId, PolicyRuleRelation policyRuleRelation, RuleContext ruleContext, RuleType ruleType, string category = "", Guid productId = new Guid(),
                                        double valueLessThan = int.MaxValue, double valueGreaterEQThan = 0, DateTime d1 = new DateTime(), DateTime d2 = new DateTime())
        {
            if (store == null)
            {
                return;
            }
            var r = CreateRule(ruleContext, ruleType, category, productId, valueLessThan, valueGreaterEQThan, d1, d2);

            switch (policyRuleRelation)
            {
            case PolicyRuleRelation.Simple:
                await CreateRuleToStoreAsync(store, username, storeId, r);

                break;

            case PolicyRuleRelation.And:
                await GeneratePolicyAndRuleAsync(store, username, storeId, r);

                break;

            case PolicyRuleRelation.Or:
                await GeneratePolicyOrRuleAsync(store, username, storeId, r);

                break;

            default:
                await GeneratePolicyConditionRuleAsync(store, username, storeId, r);

                break;
            }
        }
        //Add New / Complex Policy
        public async Task AddPolicyRule(string username, Guid storeId, PolicyRuleRelation policyRuleRelation, RuleContext ruleContext, RuleType ruleType, string category = "", Guid productId = new Guid(),
                                        double valueLessThan = int.MaxValue, double valueGreaterEQThan = 0, DateTime d1 = default(DateTime), DateTime d2 = default(DateTime))
        {
            await StorePredicatesManager.Instance.SaveRequest(++counter, "AddPolicyRule", username, storeId, policyRuleRelation, ruleContext, ruleType, category, productId, valueLessThan, valueGreaterEQThan, d1, d2);

            await marketRules.AddPolicyRule(await MarketStores.Instance.GetStoreById(storeId), username, storeId, policyRuleRelation, ruleContext, ruleType, category, productId, valueLessThan, valueGreaterEQThan, d1, d2);

            var policyData = new PolicyData(username, storeId, policyRuleRelation, ruleContext, ruleType, category, productId, valueLessThan, valueGreaterEQThan, d1, d2);

            await this.policyManager.AddPolicy(policyData);
        }
 public PolicyData(string username, Guid storeId, PolicyRuleRelation policyRuleRelation, RuleContext ruleContext, RuleType ruleType, string category,
                   Guid productId, double valueLessThan, double valueGreaterEQThan, DateTime d1, DateTime d2)
 {
     this.Username           = username;
     this.StoreId            = storeId;
     this.PolicyRuleRelation = policyRuleRelation;
     this.RuleContext        = ruleContext;
     this.RuleType           = ruleType;
     this.Category           = category;
     this.ProductId          = productId;
     this.ValueLessThan      = valueLessThan;
     this.ValueGreaterEQThan = valueGreaterEQThan;
     this.D1 = d1;
     this.D2 = d2;
 }
 internal async Task SaveRequest(int counter, string functionName, string username, Guid storeId, PolicyRuleRelation policyRuleRelation, RuleContext ruleContext, RuleType ruleType, string category, Guid productId, double valueLessThan, double valueGreaterEQThan, DateTime d1, DateTime d2)
 {
     var marketRulesRequest = new MarketRulesRequestType2(counter, functionName, username, storeId, policyRuleRelation, ruleContext, ruleType, category, productId, valueLessThan, valueGreaterEQThan, d1, d2);
     await marketDAL.AddRequestType2(marketRulesRequest);
 }
Example #5
0
 public MarketRulesRequestType2(int counter, string functionName, string username, Guid storeId, PolicyRuleRelation policyRuleRelation, RuleContext ruleContext, RuleType ruleType, string category, Guid productId, double valueLessThan, double valueGreaterEQThan, DateTime d1, DateTime d2)
 {
     this.id                 = counter;
     this.functionName       = functionName;
     this.username           = username;
     this.storeId            = storeId;
     this.policyRuleRelation = policyRuleRelation;
     this.ruleContext        = ruleContext;
     this.ruleType           = ruleType;
     this.category           = category;
     this.productId          = productId;
     this.valueLessThan      = valueLessThan;
     this.valueGreaterEQThan = valueGreaterEQThan;
     this.d1                 = d1;
     this.d2                 = d2;
 }