Should my ViewModel encapsulate the Services needed to populate it?
Currently I'm doing it as follows:
public PartialViewResult Companies(SearchViewModel search)
{
search.Summary = _entitySearchService.GetSearchDataSummary(search.SearchExpression);
search.PagedCompanies = _companyService.GetPagedEntities<Company>(search.SearchExpression);
return PartialView(search);
}
But what if SearchViewModel
populated these properties in its constructor? I could get StructureMap to pass in the interfaces to the services. Would that be a valid use of a ViewModel?