I have a master page that relies on a specific model coming from my pages. So the ending code for basically every ViewResult ends up something like this
public ActionResult Details(long store_id)
{
var store = getStore();
var model = new ClientModel<StoreModel>(store)
{
UserNotifications = new UserNotificationModel(this.CurrentUser)
};
return View(model);
}
Each one of my controllers derives from a BaseController, so i was looking to put this redundant code there, but I’m not really sure the best approach to take.
The structure for my generic ClientModel is this…
public class ClientModel<T> : ClientModel {}
public class ClientModel {}
Clarification
The StoreModel is generic and a lot of other actions use a different view model. I just wanted to show based on how it looks when impelmented.
1 Answer