Ejemplo n.º 1
0
        /// <summary>
        ///异步验证
        /// </summary>
        public static async Task DoValidationAsync(IRoleElementRespository roleElementRespository, RoleElement roleElement, string validatorType)
        {
            var roleElementValidator = new RoleElementValidator(roleElementRespository);
            var validatorReresult    = await roleElementValidator.DoValidateAsync(roleElement, validatorType);

            if (!validatorReresult.IsValid)
            {
                throw new DomainException(validatorReresult);
            }
        }
Ejemplo n.º 2
0
 public RoleElementValidator(IRoleElementRespository roleElementRespository)
 {
     RuleSet(ValidatorTypeConstants.Create, () =>
     {
         BaseValidator();
     });
     RuleSet(ValidatorTypeConstants.Modify, () =>
     {
         BaseValidator();
     });
 }
Ejemplo n.º 3
0
        /// <summary>
        ///异步验证
        /// </summary>
        public static async Task DoValidationAsync(IRoleElementRespository roleElementRespository, IEnumerable <RoleElement> roleElements, string validatorType)
        {
            var roleElementValidator = new RoleElementValidator(roleElementRespository);
            var domainException      = new DomainException();

            foreach (var roleElement in roleElements)
            {
                var validatorReresult = await roleElementValidator.DoValidateAsync(roleElement, validatorType);

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

            if (domainException.ValidationErrors.ErrorItems.Any())
            {
                throw domainException;
            }
        }
Ejemplo n.º 4
0
 public RoleElementAppService(IRoleElementRespository roleElementRespository,
                              IMapper mapper)
 {
     _roleElementRespository = roleElementRespository;
     _mapper = mapper;
 }