public ActionResult Menu()
        {
            var pages = this.session.Query<Page>()
                .Where(p => !p.Deleted)
                .ToList();

            pages.Insert(0, Page.HomePage);

            var mapper = new PageToPageViewModelMapper(this.session, this.Url);
            var pageViewModels = pages.Select(p => mapper.Map(p, false));

            return this.View(pageViewModels);
        }
Exemplo n.º 2
0
        public ActionResult ViewPage(string pageSlug)
        {
            var pageFactory = new PageFactory(this.session);
            var page = pageFactory.CreateFromSlug(pageSlug);
            if (page == null)
            {
                return new HttpNotFoundResult("No such page.");
            }

            var pageToPageViewModelMapper = new PageToPageViewModelMapper(this.session, this.Url);
            var pageViewModel = pageToPageViewModelMapper.Map(page);

            return this.View(pageViewModel);
        }
        private PageViewModel GetPageViewModel(string pageId)
        {
            var pageToPageViewModelMapper = new PageToPageViewModelMapper(this.session, this.urlHelper);

            if (string.IsNullOrEmpty(pageId))
            {
                return pageToPageViewModelMapper.Map(Page.HomePage, false);
            }

            var page = this.session.Load<Page>(pageId);
            if (page == null)
            {
                return pageToPageViewModelMapper.Map(Page.HomePage, false);
            }

            return pageToPageViewModelMapper.Map(page, false);
        }
        private static PageViewModel GetMappedPageViewModel(IDocumentSession session, Page page)
        {
            var testableUrlHelperFactory = new TestableUrlHelperFactory();
            var urlHelper = testableUrlHelperFactory.Create();

            var pageToPageViewModelMapper = new PageToPageViewModelMapper(session, urlHelper);
            return pageToPageViewModelMapper.Map(page);
        }