public ActionResult Index(string page = "") { if (page == "") { page = "home"; } if (_pageservice.GetAllPages().Where(x => x.Slug.Equals(page)).Count() == 0) { this.RedirectToAction <PagesController>(c => c.Index("")); } Page foundpage = _pageservice.GetAllPages().Where(x => x.Slug == page).FirstOrDefault(); if (!String.IsNullOrEmpty(foundpage.Slug)) { ViewBag.PageTitle = foundpage.Title; } if (foundpage.hasSidebar) { ViewBag.Sidebar = "yes"; } else { ViewBag.Sidebar = "no"; } var result = Mapper.Map <Page, PageVM>(foundpage); return(View(result)); }
public ActionResult Index() { IEnumerable <Page> pages = _pagesService.GetAllPages(); var result = Mapper.Map <IEnumerable <Page>, IEnumerable <PageVM> >(pages); return(View(result)); }