public void ValidateOperators() { if (!IsRange) { return; } var operators = (LowerBoundOperator, UpperBoundOperator); switch (operators) { case ("<", "<"): case ("<", "<="): case ("<=", "<"): case ("<=", "<="): case (">", ">"): case (">=", ">"): case (">", ">="): case (">=", ">="): return; default: DomainExceptionCode.Throw(DomainError.D033, this); break; } }
public void ReplaceThresholds(List <Threshold> thresholds) { var listMetricStatusIds = thresholds.Select(t => t.MetricStatusId).ToList(); var listDistinctIds = listMetricStatusIds.Distinct().ToList(); if (!listDistinctIds.SequenceEqual(listMetricStatusIds)) { DomainExceptionCode.Throw(DomainError.D023, this, Thresholds); } if (thresholds.Any(t => t.MetricId > 0 && t.MetricId != Id)) { DomainExceptionCode.Throw(DomainError.D022, this, thresholds); } var listRemove = Thresholds.Except(thresholds, Threshold.ThresholdComparer).ToList(); var listAddNew = thresholds.Except(Thresholds, Threshold.ThresholdComparer).ToList(); var listUpdate = thresholds.Intersect(Thresholds, Threshold.ThresholdComparer).ToList(); listRemove.ForEach(i => _thresholds.Remove(i)); listAddNew.ForEach(i => _thresholds.Add(i)); listUpdate.ForEach(i => { var item = Thresholds.First(t => t.MetricId == i.MetricId && t.MetricStatusId == i.MetricStatusId); item.UpdateValue(item.MetricStatusId, item.MetricId, i.UpperBound, i.LowerBound, i.UpperBoundOperator, i.LowerBoundOperator, i.IsRange, i.Value); }); ValidateThresholds(); ThresholdMustHaveDifferentMetricStatus(); }
public void ValueTypeIsSelect_SelectValueMustHaveValue() { if (ValueType == DoDHelper.ValueTypeSelect && string.IsNullOrEmpty(SelectValues)) { DomainExceptionCode.Throw(DomainError.D029, this); } }
public void ValueTypeMustBeValid() { var validValueTypes = new[] { DoDHelper.ValueTypeText, DoDHelper.ValueTypeNumber, DoDHelper.ValueTypeSelect }; if (!validValueTypes.Contains(ValueType)) { DomainExceptionCode.Throw(DomainError.D024, this); } }
public void ValidateThresholds() { if (Thresholds.Count() > 3) { DomainExceptionCode.Throw(DomainError.D025, this, Thresholds); } foreach (var threshold in Thresholds) { switch (ValueType, threshold.IsRange) {
public void ValidateIsRange() { if (IsRange) { if (!string.IsNullOrEmpty(Value)) { DomainExceptionCode.Throw(DomainError.D030, this, Metric); } if (LowerBound == null || UpperBound == null || LowerBoundOperator == null || UpperBoundOperator == null) { DomainExceptionCode.Throw(DomainError.D032, this, Metric); } } }
public void AddEditQualityReport(QualityReport item) { // TODO Validate Quality Report data if (item.ReOpenBugs > item.CriticalBugs + item.MajorBugs + item.MinorBugs) { DomainExceptionCode.Throw(DomainError.D039, this); } if (item.Id == 0) { _qualityReports.Add(item); } else { var itemInDb = _qualityReports.First(b => b.Id == item.Id); itemInDb.UpdateValue(item); } this.ValidateQualityReport(); }
public DomainException(DomainExceptionCode code) : base(code.ToString()) { Code = code; }