I'm confused about what is the best way to call the validator. From within my method of business or outside.
example:
invoke at controller:
Thanks
[]s
example:
invoke at controller:
var uow = UnitOfWorkFactory.GetInstance();
var userBLL= new UserBLL(uow);
var validator = new UserValidator(userBLL);
var user = .....;
validator.Validade(user);
if (validator.IsValid) {
....
}
else {
....
}
or at business layer:var uow = UnitOfWorkFactory.GetInstance();
var userBLL= new UserBLL(uow);
try {
var user = .....;
// Inside of the method "Save" I create and invoke the validator adding the result in a exception.
userBLL.Save(user);
}
catch {
/// Error of the validator
}
What is the best way? Or there are other options?Thanks
[]s