public ActionResult CreateRule(policyData vData, int linkId) { vData.PolicyLink = new PolicyLinkEntity(linkId); vData.Policy = vData.PolicyLink.Policy; vData.Rule = new RuleEntity(); vData.Rule.Policy = vData.Policy; vData.Rule.Condition.Type = constants.conditionType; vData.Condition = vData.Rule.Condition; vData.Condition.CombineAnd = true; RuleCollection maxColl = new RuleCollection(); PredicateExpression pe = new PredicateExpression(RuleFields.PolicyId == vData.PolicyLink.PolicyId); object maxObj = maxColl.GetScalar(RuleFieldIndex.Order, null, AggregateFunction.Max, pe); if (maxObj != null && maxObj != DBNull.Value) { vData.Rule.Order = (int)maxObj + 1; } else { vData.Rule.Order = 0; } EffectCollection ecoll = new EffectCollection(); ecoll.GetMulti((EffectFields.Name == "permit")); vData.Rule.EffectId = ecoll[0].Id; vData.Rule.Save(true); return(RedirectToAction("EditRule", new { id = vData.Rule.Id, linkId = linkId })); }
public ActionResult CreateRule(policyData vData, int linkId) { vData.PolicyLink = new PolicyLinkEntity(linkId); vData.Policy = vData.PolicyLink.Policy; vData.Rule = new RuleEntity(); vData.Rule.Policy = vData.Policy; vData.Rule.Condition.Type = constants.conditionType; vData.Condition = vData.Rule.Condition; vData.Condition.CombineAnd = true; RuleCollection maxColl = new RuleCollection(); PredicateExpression pe = new PredicateExpression(RuleFields.PolicyId == vData.PolicyLink.PolicyId); object maxObj = maxColl.GetScalar(RuleFieldIndex.Order, null, AggregateFunction.Max, pe); if (maxObj != null && maxObj != DBNull.Value) vData.Rule.Order = (int)maxObj + 1; else vData.Rule.Order = 0; EffectCollection ecoll = new EffectCollection(); ecoll.GetMulti((EffectFields.Name == "permit")); vData.Rule.EffectId = ecoll[0].Id; vData.Rule.Save(true); return RedirectToAction("EditRule", new { id = vData.Rule.Id, linkId = linkId }); }