Exemplo n.º 1
0
        public ActionResult Details(string postSlug)
        {
            Post post = CacheHelper.FromCacheOrExecute(db, () => db.GetCompletePost(postSlug, HttpContext), "FujiyBlog.Core.Extensions.QueryableExtensions.GetCompletePost(" + postSlug + ") as " + User.Identity.Name);

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

            ViewBag.Title       = post.Title;
            ViewBag.Keywords    = string.Join(",", post.PostTags.Select(x => x.Tag.Name).Concat(post.PostCategories.Select(x => x.Category.Name)));
            ViewBag.Description = post.Description;

            Post previousPost = CacheHelper.FromCacheOrExecute(db, () => db.Posts.GetPreviousPost(post, HttpContext), "FujiyBlog.Core.Extensions.QueryableExtensions.GetPreviousPost(" + post.Id + ") as " + User.Identity.Name);
            Post nextPost     = CacheHelper.FromCacheOrExecute(db, () => db.Posts.GetNextPost(post, HttpContext), "FujiyBlog.Core.Extensions.QueryableExtensions.GetNextPost(" + post.Id + ") as " + User.Identity.Name);

            PostSummary postDetails = new PostSummary
            {
                Post          = post,
                ShowFullPost  = true,
                CommentsTotal = post.Comments.Count,
                PreviousPost  = previousPost,
                NextPost      = nextPost,
            };

            return(View("Details", postDetails));
        }