예제 #1
0
        public ActionResult Details(int id)
        {
            #region Details

            var blogDetails = Articles.GetBlogByID(id);

            if (blogDetails == null)
            {
                return(HttpNotFound());
            }

            try
            {
                var user = Identity.OSUsers.GetByID(blogDetails.UserID);
                blogDetails.UserTitle = user.Firstname + " " + user.Lastname;
            }
            catch (Exception)
            {
                blogDetails.UserTitle = StaticValues.HomeTitle;
            }

            blogDetails.Text = HttpUtility.HtmlDecode(blogDetails.Text);

            #endregion Details

            var latestPosts    = Articles.GetLatestPosts(blogDetails.GroupID);
            var latestComments = ArticleComments.GetLatestComments(ArticleType.Blog, 6, blogDetails.GroupID);
            var comments       = ArticleComments.GetByArticleID(id);
            var relatedPosts   = RelatedArticles.GetRelatedArticles(id);
            var group          = Groups.GetByID(blogDetails.GroupID);

            #region Products

            var products = Products.GetRandom();
            Products.FillProductItems(UserID, products, StaticValues.RelatedProductImageSize);

            var shopProducts = new RelatedProductSettings
            {
                Products = products,
                Title    = "فروشگاه آنلاین استور"
            };

            #endregion Products

            // increase Visits
            increaseVisits(id);

            BlogDetail model = new BlogDetail
            {
                BlogDetails    = blogDetails,
                LatestComments = latestComments,
                LatestPosts    = latestPosts,
                Comments       = comments,
                RelatedPosts   = relatedPosts,
                Products       = shopProducts
            };

            ViewBag.Title       = blogDetails.Title;
            ViewBag.Description = blogDetails.Summary;
            ViewBag.Keywords    = group.Title + ", " + group.TitleEn +
                                  ", " + blogDetails.Title.Split(' ').Aggregate((a, b) => b + ", " + a);
            ViewBag.OGType  = "article";
            ViewBag.OGImage = StaticValues.WebsiteUrl + StaticPaths.ArticleImages + blogDetails.Image;

            return(View(url + "Details.cshtml", model: model));
        }