/// <summary> ///异步验证 /// </summary> public static async Task DoValidationAsync(IEmployeeElementRespository employeeElementRespository, EmployeeElement employeeElement, string validatorType) { var employeeElementValidator = new EmployeeElementValidator(employeeElementRespository); var validatorReresult = await employeeElementValidator.DoValidateAsync(employeeElement, validatorType); if (!validatorReresult.IsValid) { throw new DomainException(validatorReresult); } }
public EmployeeElementValidator(IEmployeeElementRespository employeeElementRespository) { RuleSet(ValidatorTypeConstants.Create, () => { BaseValidator(); }); RuleSet(ValidatorTypeConstants.Modify, () => { BaseValidator(); }); }
/// <summary> ///异步验证 /// </summary> public static async Task DoValidationAsync(IEmployeeElementRespository employeeElementRespository, IEnumerable <EmployeeElement> employeeElements, string validatorType) { var employeeElementValidator = new EmployeeElementValidator(employeeElementRespository); var domainException = new DomainException(); foreach (var employeeElement in employeeElements) { var validatorReresult = await employeeElementValidator.DoValidateAsync(employeeElement, validatorType); if (!validatorReresult.IsValid) { domainException.AddErrors(validatorReresult); } } if (domainException.ValidationErrors.ErrorItems.Any()) { throw domainException; } }
public EmployeeElementAppService(IEmployeeElementRespository employeeElementRespository, IMapper mapper) { _employeeElementRespository = employeeElementRespository; _mapper = mapper; }