private static RuleCriteriaValue CreateCriteriaValue(RuleCriteriaValueDto dto) { var criteriaDefinition = DefinedCriteriaDefinitions.All.FirstOrDefault(x => x.Name == dto.Name); var operatorObj = GetOperator(dto.Operator); return(new RuleCriteriaValue(dto.Value as Value, operatorObj, criteriaDefinition)); }
private static void ChangeCriteriaDefinition(RuleCriteriaValueDto criteria) { var criteriaDefinition = GetFirstBestMatchedCriteriaDef(criteria); var criteriaDefOperator = criteriaDefinition.Type.Operators.First(); criteria.Name = criteriaDefinition.Name; if (criteria.Operator.Type != criteriaDefOperator.Type) { criteria.Operator = criteriaDefOperator.ToDto(); criteria.Value = criteriaDefOperator.DefaultValue; } }
private static CriteriaDefinition GetFirstBestMatchedCriteriaDef(RuleCriteriaValueDto criteria) { return(DefinedCriteriaDefinitions.All.FirstOrDefault(x => x.Type.Name == criteria.Operator.Type) ?? DefinedCriteriaDefinitions.All.First()); }