public OrganizationElementValidator(IOrganizationElementRespository organizationElementRespository)
 {
     RuleSet(ValidatorTypeConstants.Create, () =>
     {
         BaseValidator();
     });
     RuleSet(ValidatorTypeConstants.Modify, () =>
     {
         BaseValidator();
     });
 }
Пример #2
0
        /// <summary>
        ///异步验证
        /// </summary>
        public static async Task DoValidationAsync(IOrganizationElementRespository organizationElementRespository, IEnumerable <OrganizationElement> organizationElements, string validatorType)
        {
            var organizationElementValidator = new OrganizationElementValidator(organizationElementRespository);
            var domainException = new DomainException();

            foreach (var organizationElement in organizationElements)
            {
                var validatorReresult = await organizationElementValidator.DoValidateAsync(organizationElement, validatorType);

                if (!validatorReresult.IsValid)
                {
                    domainException.AddErrors(validatorReresult);
                }
            }

            if (domainException.ValidationErrors.ErrorItems.Any())
            {
                throw domainException;
            }
        }
 public OrganizationElementAppService(IOrganizationElementRespository organizationElementRespository,
                                      IMapper mapper)
 {
     _organizationElementRespository = organizationElementRespository;
     _mapper = mapper;
 }