public IActionResult Index(string name, int?page) { var pages = _pageService.GetAll().ToList(); if (name == null) { name = "Home"; } var currentPage = pages.FirstOrDefault(x => x.Name.ToLower() == name.ToLower()); if (currentPage == null) { var settings = _settingService.GetAllSettingsDictionary(); return(View("Error", settings)); } var sections = _sectionService.GetAllSectionsForPage(currentPage.Id); var model = new MasterViewModel { Sections = sections, Menu = _menuService.GetMainMenu(), Nodes = _pageService.GetNodesDictionary(name), Settings = _settingService.GetAllSettingsDictionary() }; return(View("MasterPage", model)); }
// GET: Section public IActionResult Index(SectionViewModel model) { if (model.PageId == null) { ViewBag.Pages = new SelectList(_pageService.GetAll(), "Id", "Name"); var emptyModel = new SectionViewModel(); return(View("Page", emptyModel)); } model.Sections = _sectionService.GetAllSectionsForPage(model.PageId); return(View(model)); }
// GET: Page/Details/5 public IActionResult Details(int?id) { if (id == null) { return(HttpNotFound()); } Page page = _pageService.GetById(id); if (page == null) { return(HttpNotFound()); } PageViewModel model = new PageViewModel { Page = page, Sections = _sectionService.GetAllSectionsForPage(id), IsInMenu = _menuService.CheckIfPageExistsInMenu(page) }; return(View(model)); }