예제 #1
0
        public void SaveRuleSet(ref Ruleset ruleSet)
        {
            if (ruleSet == null)
            {
                return;
            }

            var ruleName         = ruleSet.Name;
            var ruleMajorVersion = ruleSet.MajorVersion;
            var ruleMinorVersion = ruleSet.MinorVersion;

            var existingRuleSet = _rulesRepository.FindBy <Ruleset>(r => r.Name == ruleName && r.MajorVersion == ruleMajorVersion && r.MinorVersion == ruleMinorVersion).FirstOrDefault();

            if (existingRuleSet != null)
            {
                var history = new RulesetHistory()
                {
                    Name         = existingRuleSet.Name,
                    MajorVersion = existingRuleSet.MajorVersion,
                    MinorVersion = existingRuleSet.MinorVersion,
                    RuleSet      = existingRuleSet.RuleSetDefinition,
                    Status       = existingRuleSet.Status,
                    AssemblyPath = existingRuleSet.AssemblyPath,
                    ActivityName = existingRuleSet.ActivityName,
                    ModifiedBy   = existingRuleSet.ModifiedBy,
                    ModifiedDate = DateTime.Now
                };

                _rulesRepository.Add(history);
                _rulesRepository.Update(ruleSet);
                _rulesRepository.Save();
            }
            else
            {
                _rulesRepository.Add(ruleSet);
                _rulesRepository.Save();
            }
        }
예제 #2
0
        public int Save(RulesRequest ruleRequest)
        {
            var rules = new Rules();

            //rules.CountryId = ruleRequest.CountryId;
            rules.AdditionAmount    = ruleRequest.AdditionAmount;
            rules.DeductionAmount   = ruleRequest.DeductionAmount;
            rules.IsFixedFigure     = ruleRequest.IsFixedFigure;
            rules.RelatedToItemId   = ruleRequest.RelatedToItemId;
            rules.SalaryItemId      = ruleRequest.SalaryItemId;
            rules.RelatedPercentage = ruleRequest.RelatedPercentage;
            rules.Amount            = ruleRequest.Amount;
            rules.Conditions        = new List <Conditions>();
            foreach (var item in ruleRequest.Conditions)
            {
                item.Rules = null;
                rules.Conditions.Add(item);
            }
            return(_rulesRepository.Save(rules));
        }