/// <summary> ///异步验证 /// </summary> public static async Task DoValidationAsync(IRolesRespository rolesRespository, Roles roles, string validatorType) { var rolesValidator = new RolesValidator(rolesRespository); var validatorReresult = await rolesValidator.DoValidateAsync(roles, validatorType); if (!validatorReresult.IsValid) { throw new DomainException(validatorReresult); } }
public RolesValidator(IRolesRespository rolesRespository) { RuleSet(ValidatorTypeConstants.Create, () => { BaseValidator(); }); RuleSet(ValidatorTypeConstants.Modify, () => { BaseValidator(); }); }
/// <summary> ///异步验证 /// </summary> public static async Task DoValidationAsync(IRolesRespository rolesRespository, IEnumerable <Roles> roless, string validatorType) { var rolesValidator = new RolesValidator(rolesRespository); var domainException = new DomainException(); foreach (var roles in roless) { var validatorReresult = await rolesValidator.DoValidateAsync(roles, validatorType); if (!validatorReresult.IsValid) { domainException.AddErrors(validatorReresult); } } if (domainException.ValidationErrors.ErrorItems.Any()) { throw domainException; } }
public RolesAppService(IRolesRespository rolesRespository, IMapper mapper) { _rolesRespository = rolesRespository; _mapper = mapper; }