title: How to architect this ASP.NET n-tier solution?
body: <p>I have a problem trying to layout my VS solution and I would like some suggestions, please.</p>
  
  <p>Currently, my solution layout looks like the following project:-</p>
  
  <pre><code>Foo.Models
  Foo.Repositories
  Foo.Services
  Foo.Web (an ASP.NET MVC application)
  </code></pre>
  
  <p>my website (<code>Foo.Web</code>) calls various methods on the <code>Foo.Services</code> namespace. The idea here is that the <code>Services</code> handle all the <em>business logic</em>. The <code>Model</code> namespace are just <code>POCO</code> objects. <code>Repositories</code> namespace is self explanitory.</p>
  
  <p><em>Constructor Dependency Injection</em> with interfaces handles the black magic of the what layer requires what component.</p>
  
  <blockquote>
    <p>Problem: I wish to add some Windows
    Workflow Foundation (WWF) code into
    the solution, but put this WWF code in
    the same Foo.Services.dll.</p>
  </blockquote>
  
  <p>To do this i need to make another project of type <code>Workflow</code>. This workflow has activities, which call the Foo.Services methods. As such, my website now has to call either the services method OR the workflow methods, to do stuff. </p>
  
  <p>I was hoping that the website only ever calls the <code>Services</code> namespace to do stuff. </p>
  
  <p>After all, the service is the main interface between the UI and the business logic, IMO. The fact that I technically use WWF shouldn't be a concern for someone coding in the IUI frontend.</p>
  
  <p>Because the workflow dll calls methods in the Services dll, the Services dll cannot call methods in the Workflow because of <em>circular dependency</em>.</p>
  
  <p>I also can't move all the workflow code INTO the Services dll because the Services dll needs to be some special project type (of type Windows Workflow).</p>
  
  <p>So .. i'm not sure what to do?</p>
  
  <p>How can i make it so that the consumers only reference the Services namespace for business stuff and the fact i impliment this business stuff in WWF is hidden from the consumer?</p>
  
  <p>Do i need to make a WWF project and move all my services code into that, the throw away the old service project? Doing this doesnt' sound very reusable. What happens if i decide to not use WWF for handling certain pipline actions and use something else? </p>
  
  <p>Here's some code to help explain.</p>
  
  <pre><code>HomeController.cs
  public ActionResult Index()
  {
     // StockService was created using constructor dependency injection.
     var viewData = _stockService.GetStocks(StockType.MostPopular);
     return (viewData)
  }
  
  StockService.cs
  public class StockService : IStockService
  {
      public IEnumerable&lt;Stock&gt; GetStocks(StockType stockType)
      {
          // Dependency Injection defines if the Pipeline is WWF
          // or something else (eg. plain ole functions).
          var stocks = _stockPipeline.GetStocks(stockType);
  
          // Cache result.
  
          // Update repostiory. (example of calling the repository)
          _sqlRepostiory.SaveSomeRandomData("Jon Skeet Was Here.");
  
          return stocks. // Returns a POCO.
      }
  }
  </code></pre>
  
  <p>Thanks peeps.</p>