Beispiel #1
0
        /// <summary>
        ///异步验证
        /// </summary>
        public static async Task DoValidationAsync(IEmployeeMenuRespository employeeMenuRespository, EmployeeMenu employeeMenu, string validatorType)
        {
            var employeeMenuValidator = new EmployeeMenuValidator(employeeMenuRespository);
            var validatorReresult     = await employeeMenuValidator.DoValidateAsync(employeeMenu, validatorType);

            if (!validatorReresult.IsValid)
            {
                throw new DomainException(validatorReresult);
            }
        }
Beispiel #2
0
 public EmployeeMenuValidator(IEmployeeMenuRespository employeeMenuRespository)
 {
     RuleSet(ValidatorTypeConstants.Create, () =>
     {
         BaseValidator();
     });
     RuleSet(ValidatorTypeConstants.Modify, () =>
     {
         BaseValidator();
     });
 }
Beispiel #3
0
        /// <summary>
        ///异步验证
        /// </summary>
        public static async Task DoValidationAsync(IEmployeeMenuRespository employeeMenuRespository, IEnumerable <EmployeeMenu> employeeMenus, string validatorType)
        {
            var employeeMenuValidator = new EmployeeMenuValidator(employeeMenuRespository);
            var domainException       = new DomainException();

            foreach (var employeeMenu in employeeMenus)
            {
                var validatorReresult = await employeeMenuValidator.DoValidateAsync(employeeMenu, validatorType);

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

            if (domainException.ValidationErrors.ErrorItems.Any())
            {
                throw domainException;
            }
        }
Beispiel #4
0
 public EmployeeMenuAppService(IEmployeeMenuRespository employeeMenuRespository,
                               IMapper mapper)
 {
     _employeeMenuRespository = employeeMenuRespository;
     _mapper = mapper;
 }