public override IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            var contactTypes = ContactTypeExtension.GetItems();
            var enterType    = contactTypes.Where(type => type.Name == Type).FirstOrDefault();

            if (enterType == null)
            {
                yield return(new ValidationResult(
                                 $"{nameof(Type)} is incorrect.", new[] { nameof(Type) }));
            }
        }
Exemple #2
0
 public DataResponse <List <ContactTypeItem> > GetContactTypes()
 {
     try
     {
         var contactTypes = ContactTypeExtension.GetItems();
         return(new DataResponse <List <ContactTypeItem> >(contactTypes));
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         return(new DataResponse <List <ContactTypeItem> >(ex.Message));
     }
 }