Exemplo n.º 1
0
        public ActionResult Item(string slug) {
            if (!Services.Authorizer.Authorize(StandardPermissions.AccessFrontEnd, T("Couldn't view page")))
                return new HttpUnauthorizedResult();

            var correctedSlug = _pageSlugConstraint.FindSlug(slug);
            if (correctedSlug == null)
                return new NotFoundResult();

            var page = _pageService.Get(correctedSlug);
            if (page == null)
                return new NotFoundResult();

            var model = new PageViewModel {
                Page = Services.ContentManager.BuildDisplayModel(page, "Detail")
            };
            return View(model);
        }
        public ActionResult GetHomePage(int itemId) {
            var page = _pageService.Get(itemId);
            if (page == null)
                return new NotFoundResult();

            var correctedSlug = _pageSlugConstraint.FindSlug(page.Slug);
            if (correctedSlug == null)
                return new NotFoundResult();

            page = _pageService.Get(correctedSlug);
            if (page == null)
                return new NotFoundResult();

            var model = new PageViewModel {
                Page = Services.ContentManager.BuildDisplayModel(page, "Detail")
            };

            return new ViewResult {
                ViewName = "~/Modules/Orchard.Pages/Views/Page/Item.ascx",
                ViewData = new ViewDataDictionary<PageViewModel>(model)
            };
        }