예제 #1
0
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            if (MeterNumber == true && !MeterNumberLength.HasValue)
            {
                yield return(new ValidationResult("Meter Number Length is Required.", new[] { "MeterNumberLength" }));
            }

            if (MeterNumberLength.HasValue && MeterNumberLength.GetValueOrDefault(0) < 5)
            {
                yield return(new ValidationResult("Meter Number Length must be at least 5.", new[] { "MeterNumberLength" }));
            }
        }
예제 #2
0
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            if (Business.AppLogic.ProgramCodeExists(Id.GetValueOrDefault(0), ProgramCode, EffectiveStartDate.Value, EffectiveEndDate.Value))
            {
                yield return(new ValidationResult("There is already an active program with this code.", new[] { "ProgramCode" }));
            }

            if (MeterNumber == true && !MeterNumberLength.HasValue)
            {
                yield return(new ValidationResult("Meter Number Length is Required.", new[] { "MeterNumberLength" }));
            }

            if (MeterNumberLength.HasValue && MeterNumberLength.GetValueOrDefault(0) < 5)
            {
                yield return(new ValidationResult("Meter Number Length must be at least 5.", new[] { "MeterNumberLength" }));
            }
        }