We have a service layer within our MVC3 application using an almost identical approach as described here: http://www.asp.net/mvc/tutorials/older-versions/models-(data)/validating-with-a-service-layer-cs
The service layer doesn't depend on MVC.
The issue is we have a legacy webforms application that needs to also create these services and I'm trying to come up with the best approach on how to instantiate these services. It would also be nice to have the Validate() method return the validation errors.
An individual service requires an IValidationDictionary at construction which within our MVC app we simply use the ModelStateWrapper(this.modelstate) however in Webforms we obviously don't have the concept of ModelState (as in Controller.ModelState)
So my question would be how would you construct a service layer with model validation that can be used within an MVC and Webforms application?
At this stage we're not considering an IoC
On a side note:
Am I missing something obvious with ModelStateDictionary? It's within the MVC namespace but doesn't appear to be dependant on the MVC framework? Isn't it just a wrapper for a Dictionary with a setup?