The project I’m currently working on has a Core API which is used by everything: services, web, …
This API has following layers:
- Core
- Core.Models
- Core.DataProviders
- Core.DataProviders.LinqToSql
- Core.Utils
On top of this API is my ASP.NET MVC application. This looks like this:
- Web
- Web.Models (Some Web specific objects and logic. For example a class which builds a list of quarters to help me render a day in a scheduling table.)
- Web.Extensions (Html Helpers, Controller base..)
- Web.ViewModels (Composite objects to pass to the View.)
- Web.Services (Layer which communicates with the Core and Web.Models. This layer builds ViewModels for my Controllers. Helps keeping my Controllers clean.)
Any serious flaws in this setup?
A more specific question: I need to parse some things coming from my View before I can pass them to the Core. Should I handle this in the Controller or in the Service layer?
Generally speaking data submitted from the view should be parsed by a ModelBinder, falling back to the Controller if using a ModelBinder doesn’t seem to make sense.
Parsing in an application service makes sense if multiple sources can submit the data in the same format (like web service or file system persistance).