/// <summary> ///异步验证 /// </summary> public static async Task DoValidationAsync(IRelationEmployeeRoleRespository relationEmployeeRoleRespository, RelationEmployeeRole relationEmployeeRole, string validatorType) { var relationEmployeeRoleValidator = new RelationEmployeeRoleValidator(relationEmployeeRoleRespository); var validatorReresult = await relationEmployeeRoleValidator.DoValidateAsync(relationEmployeeRole, validatorType); if (!validatorReresult.IsValid) { throw new DomainException(validatorReresult); } }
public RelationEmployeeRoleValidator(IRelationEmployeeRoleRespository relationEmployeeRoleRespository) { RuleSet(ValidatorTypeConstants.Create, () => { BaseValidator(); }); RuleSet(ValidatorTypeConstants.Modify, () => { BaseValidator(); }); }
/// <summary> ///异步验证 /// </summary> public static async Task DoValidationAsync(IRelationEmployeeRoleRespository relationEmployeeRoleRespository, IEnumerable <RelationEmployeeRole> relationEmployeeRoles, string validatorType) { var relationEmployeeRoleValidator = new RelationEmployeeRoleValidator(relationEmployeeRoleRespository); var domainException = new DomainException(); foreach (var relationEmployeeRole in relationEmployeeRoles) { var validatorReresult = await relationEmployeeRoleValidator.DoValidateAsync(relationEmployeeRole, validatorType); if (!validatorReresult.IsValid) { domainException.AddErrors(validatorReresult); } } if (domainException.ValidationErrors.ErrorItems.Any()) { throw domainException; } }
public RelationEmployeeRoleAppService(IRelationEmployeeRoleRespository relationEmployeeRoleRespository, IMapper mapper) { _relationEmployeeRoleRespository = relationEmployeeRoleRespository; _mapper = mapper; }