1 に答える
I'd take it later you query the service for any validation errors?
Either query service immediately after validation then reset the errors, or have the method call the return validation errors. If you do either of those you can prefix them with( prefix(this validationDictionaryObject, string pfx) ) an extension method for the dictionary, the api wouldn't be too bad that way. A second extension method (HasErrors()) for the dictionary would do the same as your boolean return
For the problem you are having alone, i tend to eschew querying the service for errors.
It's convenient to have the service collect them all, but then you are adding error state to a service that doesn't really belong, its not that the service is broken, but one model it checked was. If you need to call that service again (like you are doing) it has old state. You have to manage that. Either that or return errors because after all, its a validation method. Have it return validation results. :)
var errs = service.ValidateCustomer(sellinCustomer);
if (errs.HasErrors()){
errs.Prefix("SellingCustomer");
//add to model state dictionary for view here.
}