Beispiel #1
0
        public void DeleteRule(RuleDto ruleDto)
        {
            if (ruleDto == null)
            {
                throw new ArgumentNullException(nameof(ruleDto));
            }

            var toDelete = ruleDto.Clone();

            _ruleRecords.Remove(toDelete.Id);
        }
Beispiel #2
0
        public RuleDto UpdateRule <TTarget, TComparison>(RuleDto ruleDto)
        {
            if (ruleDto == null)
            {
                throw new ArgumentNullException(nameof(ruleDto));
            }

            var toUpdate = ruleDto.Clone();

            if (ruleDto.Id == null || !_ruleRecords.ContainsKey(toUpdate.Id))
            {
                return(AddRule <TTarget, TComparison>(toUpdate));
            }

            DeleteRule(toUpdate);
            return(AddRule <TTarget, TComparison>(toUpdate));
        }
Beispiel #3
0
        public RuleDto AddRule <TTarget, TComparison>(RuleDto ruleDto)
        {
            if (ruleDto == null)
            {
                throw new ArgumentNullException(nameof(ruleDto));
            }

            var toAdd = ruleDto.Clone();

            if (string.IsNullOrWhiteSpace(ruleDto.Id))
            {
                toAdd.Id = Guid.NewGuid().ToString();
            }

            _ruleRecords.Add(toAdd.Id, toAdd);

            return(toAdd);
        }