public override ValidationResult Validate(object value, CultureInfo cultureInfo) { Symptom symptom = (value as BindingGroup).Items[0] as Symptom; if (symptom.Name == null || symptom.Name.Length == 0) { return(new ValidationResult(false, "The name value can't be empty")); } if (symptom.Name != null && symptom.Name.Length > 50) { return(new ValidationResult(false, "Symptom name is too long. Length should be smaller than 50 characters")); } if (symptom.QuickDescription != null && symptom.QuickDescription.Length > 50) { return(new ValidationResult(false, "Symptom description is too long. Length should be smaller than 50 characters")); } if (symptom.GeneralizationDegree < 0 || symptom.GeneralizationDegree > 100) { return(new ValidationResult(false, "Value of generalization should be in range (0, 100)")); } DiseaseDatabaseEntities tempContext = new DiseaseDatabaseEntities(); if (tempContext.Symptoms.Count(s => (s.Name == symptom.Name) && (s.Id != symptom.Id)) > 0) { return(new ValidationResult(false, "Symptom names have to be unique")); } return(ValidationResult.ValidResult); }
private void SymptomViewSource_Filter(object sender, FilterEventArgs e) { Symptom cat = e.Item as Symptom; if (cat != null) { e.Accepted = (cat.Name.ToUpper().Contains(SymptomsSearchBox.Text.ToUpper())); } }