public void DeleteRule(RuleDto ruleDto) { if (ruleDto == null) { throw new ArgumentNullException(nameof(ruleDto)); } var toDelete = ruleDto.Clone(); _ruleRecords.Remove(toDelete.Id); }
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)); }
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); }