title: Handling multiple classes in a generic controller, some pointers please
body: <p>I am using MVC3. </p>
  
  <p>I have a pretty complex document class that contains many sub classes, lets call them "dog", "cat", "sheep", "cow", "goat".</p>
  
  <p>I would like to use a generic controller to list, add and edit each of these classes.</p>
  
  <p>Listing: I can list the relevant entity by passing in document model and iterating through the relevant class.</p>
  
  <p>Edit: I need to get the id and identify the class of interest ie "dog" and then passing this as the model for editing. However next time round I may be editing a "cat" instance. Typically in MVC, as I understand it, one would ideally create a "DogController" and a "CatController". However since this document class is meant to be flexible I do not wish to hard code controllers. It may be necessary to add 2 more classes ie "horse" and "donkey".</p>
  
  <p>At the moment I am using some if/else logic to ensure that the correct View is setup and called with the correct class. However this does feel as if I am breaking some MVC rules here.</p>
  
  <p>Perhaps the answer lies in the use of a more formal ViewModel. Perhaps I can then have one of the properties as the subclass ("Dog"). Perhaps this can be swapped out at runtime using IOC?</p>
  
  <p>Thoughts and pointers appreciated?</p>
  
  <p>Thanks.</p>
  
  <p>EDIT: I have tried to create 2 version of the "edit" action with different input models</p>
  
  <pre><code>    [HttpPost]
      public ActionResult Edit(Dog DogModel){}
  
      [HttpPost]
      public ActionResult Edit(Cat CatModel){}
  </code></pre>
  
  <p>I thought that due to method overloading MVC would be able to pick the correct one when the View posted, and then applied modelbinding.</p>
  
  <p>Perhaps I am expecting too much or my understanding is lacking.</p>