示例#1
0
 public virtual void Save( IncomeRule rule )
 {
     if (rule == null) return;
     List<IncomeRule> savedRules = this.GetSavedRules( rule.CurrencyId );
     foreach (IncomeRule savedRule in savedRules) {
         if (rule.ActionId == savedRule.ActionId) {
             if (rule.Income != savedRule.Income) {
                 savedRule.Income = rule.Income;
                 savedRule.update();
             }
             return;
         }
     }
     rule.insert();
 }
示例#2
0
        //----------------------------------- 收入规则 --------------------------------------------
        public virtual IncomeRule GetRuleByActionAndCurrency( int actionId, int currencyId )
        {
            List<IncomeRule> rules = cdb.findAll<IncomeRule>();
            foreach (IncomeRule r in rules) {
                if (r.CurrencyId == currencyId && r.ActionId == actionId) return r;
            }

            // 如果不存在这条规则,则创建
            IncomeRule rule = new IncomeRule();
            rule.CurrencyId = currencyId;
            rule.ActionId = actionId;
            rule.Income = 0; // 初始值是0
            rule.insert();
            return rule;
        }