I currently have a folder structure on my MVC .NET website that I am completely at a loss as to whether it is acceptable or not. Here is an outline of the structure
[Areas]
[Area1]
[Controllers]
[Services]
[ControllerName] (relates to name of a controller)
[Command]
... class files here for performing updates,deletes from domain model for each action
[Query]
... class files here for performing getting of viewmodel from domain model for each action
[ControllerName]
...
[Models]
[ViewModels]
[ControllerName]
[Views]
[ControllerName]
[Area2]
.... (same structure as area 1)
I use the services folder hierachy for performing the code that is responsible for performing mapping of my domain model to my viewmodel and vice versa.
So, the Query folders contain classes that match the Action name it is performing the getViewModel for. e.g. if there is a action in my controller called Index, then I have an partial IndexService class in the Command and query folders.
[Query]
public partial class IndexService
{
public static myViewModel GetViewModel(model objects);
}
[Command]
public partial class IndexService
{
public void UpdateModel(myViewModel viewModel);
}
I originally had these in the same class file however the mapping is quite complex at times so the files got quite big with all their related private methods etc. Should these be different class names instead and do away with the folder hierachy? Is this overkill for what I'm trying to do which seperate the different responsibilites get/update out.
Any comments would be appreciated. If you need any more info let me know.
IndexService
with 2 methods? – Trevor Pilley Oct 12 '12 at 22:14