Adding list with data from other model than the page type?


Being fairly new to MVC and also new to a higher version if CMS than 6 R2 I asume this is a nooby question.

I have a PageType called called EducationList with just two simple string properties, Header and Body.

Under the Body I want to present a list of educations that comes from a whole other database. Actually a service with a nice model structure but not at all related to EpiServer.

In my EducatioListController I can easily get an object from the external service but how do I get that to show in the view (EducationList/Index.cshtml). The view only seems to be able to read things from the PageType Model and going via the ViewBag doesn't seem like a very elegant idea.

So... now what, is this were a View Model should be used or something else I have no clue about? I can't find any MVC tutorials on this including an EPiServer angle.

Edited, Nov 17, 2016 15:50

I actually solved it via a ViewModel combining the currentPage with my external service data and setting the properties of my new ViewModel and then setting my cshtml to have the ViewModel as model instead, yay!

Edited, Nov 17, 2016 16:53

Sounds like you took the right turn yes :)

There are a few examples in alloy project for extending viewmodels with custom properties...

Nov 17, 2016 17:12
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.