コード例 #1
0
        public async Task <ActionResult> Description(string key)
        {
            var encKey = PageHelper.EncodeTitle(key);

            if (encKey != key)
            {
                return(RedirectToActionPermanent("Description", new { key = encKey }));
            }

            try
            {
                ViewBag.User = await _auth.GetCurrentUserAsync(User);

                var vm = new PageVM <PageDescriptionVM>
                {
                    Body      = await _cache.GetOrAddAsync(key, async() => await _pages.GetPageDescriptionAsync(key)),
                    InfoBlock = await _cache.GetOrAddAsync(key, async() => await _pages.GetPageInfoBlockAsync(key))
                };

                return(View(vm));
            }
            catch (RedirectRequiredException ex)
            {
                return(RedirectToActionPermanent("Description", new { key = ex.Key }));
            }
        }
コード例 #2
0
        /// <summary>
        /// Displays the page tab.
        /// </summary>
        private async Task <ActionResult> DisplayTab <T>(string key, Func <Task <T> > bodyGetter, [CallerMemberName] string methodName = null)
            where T : PageTitleVM
        {
            var encKey = PageHelper.EncodeTitle(key);

            if (encKey != key)
            {
                return(RedirectToActionPermanent(methodName, new { key = encKey }));
            }

            try
            {
                ViewBag.User = await _auth.GetCurrentUserAsync(User);

                var vm = new PageVM <T>
                {
                    Body      = await _cache.GetOrAddAsync(key, bodyGetter),
                    InfoBlock = await _cache.GetOrAddAsync(key, async() => await _pages.GetPageInfoBlockAsync(key))
                };
                return(View(vm));
            }
            catch (RedirectRequiredException ex)
            {
                return(RedirectToActionPermanent(methodName, new { key = ex.Key }));
            }
        }
コード例 #3
0
ファイル: DraftsController.cs プロジェクト: impworks/bonsai
        public async Task <ActionResult> Preview(Guid?id)
        {
            var page = await _pages.GetPageDraftPreviewAsync(id, User);

            if (page == null)
            {
                return(NotFound());
            }

            var vm = new PageVM <PageDescriptionVM>
            {
                Body      = await _pagePresenter.GetPageDescriptionAsync(page),
                InfoBlock = await _pagePresenter.GetPageInfoBlockAsync(page)
            };

            ViewBag.IsPreview = true;
            return(View("~/Areas/Front/Views/Page/Description.cshtml", vm));
        }