/// <summary> /// Executes Rules using specified <see cref="IRuleEngineContext"/> /// </summary> /// <param name="ruleEngineContext">Context to use when executing rules.</param> /// <returns>A <see cref="RuleExecutionResult"/> containing the results of the execution pass.</returns> public RuleExecutionResult ExecuteRules(IRuleEngineContext ruleEngineContext) { var rules = ruleEngineContext.RuleSelector.SelectRules(_ruleCollection, ruleEngineContext) .Where(r => !r.IsDisabled) .OrderBy(r => r.Priority) .ToList(); rules.ForEach(rule => _ruleProcessor.Process(ruleEngineContext, rule)); var result = new RuleExecutionResult(ruleEngineContext.RuleViolationReporter); return(result); }
public async Task <IRuleProcessorResult <EntityContext> > Process(int id, int orderId) { var ruleModule = await this._ruleModuleService.InquireWithLinkedModules(id, true); var order = this.unitOfWork.OrderService.Repository .CreateQueryAsNoTracking() .Where(o => o.ID == orderId) .FirstOrDefault(); if (order == null) { throw new ArgumentException($"Order with ID: {orderId} not found"); } var entityContext = new EntityContext { Order = order }; var result = ruleProcessor.Process(ruleModule, entityContext, null, false); return(result); }