public ActionResult Index() { HomeViewModel model = new HomeViewModel(); Mapper.AddCustomMapping(typeof(IList <CalloutViewModel>).FullName, MapCallouts) .AddCustomMapping(typeof(IList <MenuItemViewModel>).FullName, MapMenuItems) .Map(CurrentPage, model); MapBaseProperties(model); model.Root = model; return(CurrentTemplate(model)); }
public ActionResult Index() { LandingPageViewModel model = new LandingPageViewModel(); Mapper.AddCustomMapping(typeof(IList <CalloutViewModel>).FullName, MapCallouts) .Map(CurrentPage, model); MapBaseProperties(model); HomeViewModel home = new HomeViewModel(); IPublishedContent root = CurrentPage.AncestorOrSelf(1); Mapper.AddCustomMapping(typeof(IList <CalloutViewModel>).FullName, MapCallouts) .AddCustomMapping(typeof(IList <MenuItemViewModel>).FullName, MapMenuItems) .Map(root, home); model.Root = home; return(CurrentTemplate(model)); }
public ActionResult Index() { ArticleViewModel model = new ArticleViewModel(); Mapper.AddCustomMapping(typeof(IList <CalloutViewModel>).FullName, MapCallouts) .Map(CurrentPage, model); MapBaseProperties(model); // if callouts is empty, load from level 2 if (model.Callouts == null || model.Callouts.Count == 0) { Log.Debug("callouts is empty - loading from level 2."); BaseViewModel sectionModel = new BaseViewModel(); IPublishedContent section = CurrentPage.AncestorOrSelf(2); Log.Debug("section: " + section.Name); Mapper.Map(section, sectionModel); model.Callouts = sectionModel.Callouts; Log.Debug("Callouts count: " + model.Callouts.Count); } else { Log.Debug("Callouts count: " + model.Callouts.Count); } // workaround for image not getting mapped IPublishedContent image = CurrentPage.GetPropertyValue <IPublishedContent>("featuredImage"); if (image != null) { model.FeaturedImage = new MediaFile(); model.FeaturedImage.Url = image.Url; model.FeaturedImage.Name = image.Name; } HomeViewModel home = new HomeViewModel(); IPublishedContent root = CurrentPage.AncestorOrSelf(1); Mapper.AddCustomMapping(typeof(IList <CalloutViewModel>).FullName, MapCallouts) .AddCustomMapping(typeof(IList <MenuItemViewModel>).FullName, MapMenuItems) .Map(root, home); model.Root = home; return(CurrentTemplate(model)); }