title: ASP.NET MVC 3 - Model Validation
body: <p>I'm just learning MVC and I have a few questions about the design/how things are supposed to work.</p>
  
  <p>I'm using MVC 3 and Razor, with Entity Framework classes (e.g. Location) and I'm going to create a buddy class with Validation annotations. In my View, I have a Partial View that renders a DevExpress TreeView (using a list of Locations) and a Form for creating/editing the Locations in the Tree. I have a LocationController, a LocationManagementView, a LocationManagementPartialView (contains the code for tree view), and a LocationModel. The LocationModel will hold the buddy class and get methods for getting children (the children are only fetched after a node is expanded). I have a service wrapper (for my service client) that will be injected using StructureMap.</p>
  
  <p>Should I inject the service wrapper into the Controller's constructor or into the Model's constructor?</p>
  
  <p>Also, my Model has get methods that use the service wrapper to fetch  data from the database (do those methods belong here in the Model?): for example, GetChildren for the tree view.</p>
  
  <p>Also, is it correct to store the Location buddy class in the Model?</p>
  
  <p>I want to make sure I design this application well, as it's part of a much bigger project. Any design pointers are much appreciated. I've been reading ScottGu's blog for the MVC stuff.</p>
  
  <p>Ref: <a href="http://weblogs.asp.net/scottgu/archive/2010/01/15/asp-net-mvc-2-model-validation.aspx" rel="nofollow">http://weblogs.asp.net/scottgu/archive/2010/01/15/asp-net-mvc-2-model-validation.aspx</a></p>