public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { if (DecisionMadeDate.IsCompleted && DecisionMadeDate.AsDateTime() < CompletedDate) { yield return (new ValidationResult(string.Format(FinancialGuaranteeDecisionResources.DecisionMadeDateNotBeforeCompleteDate, CompletedDate.ToShortDateString()), new[] { "DecisionMadeDate.Day" })); } if (!DecisionMadeDate.IsCompleted) { yield return (new ValidationResult(FinancialGuaranteeDecisionResources.DecisionMadeDateRequired, new[] { "DecisionMadeDate.Day" })); } if (DecisionMadeDate.AsDateTime() > SystemTime.UtcNow) { yield return(new ValidationResult(FinancialGuaranteeDecisionResources.DecisionMadeDateNotInFuture, new[] { "DecisionMadeDate.Day" })); } if (string.IsNullOrWhiteSpace(ReasonForRefusal)) { yield return(new ValidationResult(FinancialGuaranteeDecisionResources.ReasonForRefusalRequired, new[] { "ReasonForRefusal" })); } }
public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { if (DecisionMadeDate.IsCompleted && DecisionMadeDate.AsDateTime() < CompletedDate) { yield return(new ValidationResult(string.Format(FinancialGuaranteeDecisionResources.DecisionMadeDateNotBeforeCompleteDate, CompletedDate.ToShortDateString()), new[] { "DecisionMadeDate.Day" })); } if (!DecisionMadeDate.IsCompleted) { yield return(new ValidationResult(FinancialGuaranteeDecisionResources.DecisionMadeDateRequired, new[] { "DecisionMadeDate.Day" })); } if (DecisionMadeDate.AsDateTime() > SystemTime.UtcNow) { yield return(new ValidationResult(FinancialGuaranteeDecisionResources.DecisionMadeDateNotInFuture, new[] { "DecisionMadeDate.Day" })); } if (!ActiveLoadsPermitted.HasValue) { yield return(new ValidationResult(FinancialGuaranteeDecisionResources.ActiveLoadsPermittedRequired, new[] { "ActiveLoadsPermitted" })); } if (ActiveLoadsPermitted.HasValue && ActiveLoadsPermitted.Value <= 0) { yield return(new ValidationResult(FinancialGuaranteeDecisionResources.ActiveLoadsPermittedGreaterThanZero, new[] { "ActiveLoadsPermitted" })); } if (!IsBlanketBond.HasValue) { yield return(new ValidationResult(FinancialGuaranteeDecisionResources.IsBlanketBondRequired, new[] { "IsBlanketBond" })); } if (string.IsNullOrWhiteSpace(ReferenceNumber)) { yield return(new ValidationResult(FinancialGuaranteeDecisionResources.ReferenceNumberRequired, new[] { "ReferenceNumber" })); } if (!CoverAmount.HasValue) { yield return(new ValidationResult(FinancialGuaranteeDecisionResources.CoverAmountRequired, new[] { "CoverAmount" })); } if (CoverAmount.HasValue && CoverAmount.Value.ToString().Contains(".")) { var splitArray = CoverAmount.Value.ToString().Split('.'); if (splitArray.Length > 2 || splitArray[1].Length > 2) { yield return(new ValidationResult(FinancialGuaranteeDecisionResources.CoverAmountDecimalPlaces, new[] { "CoverAmount" })); } } if (CoverAmount.HasValue && CoverAmount.Value > (decimal)9999999.99) { yield return(new ValidationResult(FinancialGuaranteeDecisionResources.CoverAmountTooMuch, new[] { "CoverAmount" })); } if (!CalculationContinued.HasValue) { yield return(new ValidationResult(FinancialGuaranteeDecisionResources.CalculationContinuedRequired, new[] { "CalculationContinued" })); } if (CalculationContinued.HasValue && CalculationContinued.Value.ToString().Contains(".")) { var splitArray = CalculationContinued.Value.ToString().Split('.'); if (splitArray.Length > 2 || splitArray[1].Length > 2) { yield return(new ValidationResult(FinancialGuaranteeDecisionResources.CalculationContinuedDecimalPlaces, new[] { "CalculationContinued" })); } } if (CalculationContinued.HasValue && CalculationContinued.Value > (decimal)9999999.99) { yield return(new ValidationResult(FinancialGuaranteeDecisionResources.CalculationContinuedTooMuch, new[] { "CalculationContinued" })); } }