I am using MVC 2.
I have 5 view models and each has different message properties that i need to populate from the DB. The property names are different, per the message type.
In the view models, i have type available, for which i need to pull the messages.
If the type is Welcome, then i want to pull the 3 welcome messages.
I want to write a generic function that i will call from each action. This generic function will then look at the object being passed and its type property and then will fill the message properties specified in this view model. How can i accomplish this? From my actions, i don't want to call a separate function for each messages type.
I am trying to do some thing like following:
public void GetMessage(object viewModel, bool isCheckMessages)
{
viewModel = (AnnualReportWelComeViewModel)viewModel;
}
But the viewModel in this instance is not picking properties specified in AnnualReportWelComeViewModel.
Am i thinking straight here or just making it way over complicated than it needs to be?