title: C# (Web API) Multilayer (IOC) API Controller Return Type
body: <p>I am building an ASP Web API application and this time I thought I will go with the MVC pattern. I got along with most of the stuff, but there is one thing of which I am unsure. First of all my project consists of the following:</p>
  
  <ul>
  <li>Data Layer</li>
  <li>Business Layer </li>
  <li>Model Layer (just the model with the properties)</li>
  <li><p>Service Application (here are my controllers)</p>
  
  <p>every one of them in a separate project</p></li>
  </ul>
  
  <p>Lets say I have the following controller</p>
  
  <pre><code>public class TestController : ApiController
  {
      ISomeService _someBusiness;
  
      public TestController(ISomeService someBusiness)
      {
          _someBusiness = someBusiness;
      }
  
      public **SomeModelObject** GetModelObject(ind id)
      {
          return _someBusiness .GetSomeModelObject(id);
      }
  
  }
  </code></pre>
  
  <p>Now my problem is the return value of <code>GetModelObject(int id)</code>. Here it says <code>SomeModelObject</code>. That implies that my Service application (or my controller) has to know everything about the model which is being used (so I dont see the point in defining it in a separate .dll). One way would be to define the model (precisely the get/set mothods) as an interface, but I think that it would be too much that every model class has an interface (mostly because, as I said, just the properties are being stored inside the model), and despite that I just does not feel right to build an interface for a class which only stores data. So, is there any generic response type which is being used in this case (even some completely different approach), or do I have to use my model classes (or may i just always use string and it is being converted to the appropriate format by the client) ?</p>