ORM vs. CQRS/ES throwdown – Part 5 – Web UI

I’ve been tip-toeing around this topic, but I think it should be addressed now.  How are we going to access this architecture from our website?  What work is Asp.Net doing in this thing?

First off:  I am faithfully drinking the Asp.Net MVC kool-aid.  This is some great stuff, and I intend to use that web application model for this example.  I believe that MVC Views should be stupid – check that, MVC projects should be SIMPLE.  These web projects should have little to no logic, as the only purpose of this project is to emit HTML and other angle-bracket code.

Thanks to NuGet, I can easily sprinkle in the Unity IoC Container and MVC3 bindings for it.  To complete the Unity installation, I added a configuration section to web.config:

I also updated the BootStrapper class to configure the UnityContainer at application startup:

Next, I’m going to add a ProductController with a constructor that accepts an IProductRepository.  At this point, I can now swap the data access architectures in and out with a simple change in web.config.

My Index action looks very simple:

and finally, a simple index.cshtml to generate a table that outputs the details of our Products.  Piece of cake…  We can get fancy with our views later, and since this series isn’t about fancy web pages, I’ll end this post about UI here.

I’ll wire up the remaining actions and UI for the web over the next day or two, and you will find the results on the GitHub repository with one of the next posts in the series.