I have a page consisting of many user controls. The viewing model for this page is quite complex.
public class ComplexViewModel { public ObjectA ObjectAProperty { get; set; } public List<Things> ListOfThings { get; set; } public List<ThingCategories> ListOfThingCategories { get; set; } public List<ThingTypes> ListOfThingTypes { get; set; } public List<ThingOptions> ListOfThingOptions { get; set; } public int ChosenThingCategoryId { get; set; } public int ChosenThingTypeId { get; set; } public int ChosenThingOptionId { get; set; } public OtherObject ObjectData { get; set; } }
This page also has a PostModel that contains information for filtering, sorting, etc.
public class SimplePostModel { public int ChosenThingCategoryId { get; set; } public int ChosenThingTypeId { get; set; } public int ChosenThingOptionId { get; set; } public int ChosenThingFilterTypeId { get; set; } public int ChosenThingSortTypeId { get; set; } public int ChosenThingOtherId { get; set; } public int ChosenThingMoreId { get; set; } public int ChosenThingOMGId { get; set; } }
A simple PostModel is checked, and then the controller opens 3+ repositories that make several calls in each and builds a presentation model. At least my controller action has become quite large.
This is by far the most difficult page I've worked on, and it's hard for me to decide how to make it easier.
My first thought was to create a factory view model that, after checking the bindings, would call in the repository and return the ViewModel.
Then I thought about creating a custom mediation that would do a PostModel check and then humidify the ViewModel in one step.
So my question is: how do you moisten a complex presentation model?
And although I am writing this, I had the idea of ββusing Html.RenderAction and creating a model for each of the user controls that make up this beast of the page.
Update:
Repositories make calls in WCF services, the application is part of a larger SOA architecture.
source share