If I have a class similar to this:
public class Person
{
public string firstName { get; set; }
public string lastName { get; set; }
public Pet myPet { get; set; }
}
When I create a custom model binder, the Post from my form will not be sending in a Pet, it would send in data like this: firstName: "myFirstName" lastName: "myLastName" myPet: "myPetsName"
Since the Pet's name is passed in, and not the actual Pet object, the Pet object needs to be retrieved from within the model binder.
My question is, should the model binder be interacting with the Service Layer, the Repository Layer, or should it even be retrieving the Pet? The problem with the Service Layer is that I don't seem to have access to ModelState when initializing the service: ((this.ModelState) gives me an error)
_petService = new PetService(new ModelStateWrapper(this.ModelState));
If I need the model binder to create a Person object, then the Pet would need to be assigned somehow... how am I supposed to do this?
Thanks,
Matt