Beispiel #1
0
        public ActionResult EntradasBlog(int pageIndex, int pageSize, int contentId, string view)
        {
            int total         = 0;
            int?currentUserId = null;

            if (User.Identity.IsAuthenticated)
            {
                currentUserId = ((CustomPrincipal)User).UserId;
            }

            BlogEntryRepository blog    = new BlogEntryRepository(SessionCustom);
            CommentRepository   comment = new CommentRepository(SessionCustom);

            blog.Entity.ContentId = contentId;

            List <BlogEntriesPaging> blogContentEntries = blog.BlogContentEntriesPaging(pageIndex, pageSize, out total);

            foreach (BlogEntriesPaging content in blogContentEntries)
            {
                content.CollComment = comment.CommentsPagingContent(1, 3, out total, contentId);
            }

            if (string.IsNullOrEmpty(view))
            {
                view = "_ContentBlogEntriesList";
            }

            return(this.View(view, blogContentEntries));
        }
Beispiel #2
0
        /// <summary>
        /// Bind the context and the session with the content
        /// </summary>
        /// <param name="context">Context page</param>
        /// <param name="session">Session object</param>
        /// <param name="id">Content ID</param>
        /// <param name="userId">current user ID</param>
        public void Bind(HttpContextBase context, ISession session, int?id, int?userId, int?LanguageId)
        {
            ContentRepository contentrepository = new ContentRepository(session);

            if (contentrepository.Entity != null)
            {
                ChallengeRepository  challengepository = new ChallengeRepository(session);
                FileattachRepository file = new FileattachRepository(session);
                IdeaRepository       idea = new IdeaRepository(session);

                contentrepository.Entity.ContentId = id;
                contentrepository.LoadByKey();

                if (contentrepository.Entity.Frienlyname != null)
                {
                    file.Entity.ContentId =
                        challengepository.Entity.ContentId =
                            contentrepository.Entity.ContentId;

                    challengepository.LoadByKey();

                    this.ObjContent   = contentrepository.Entity;
                    this.ObjChallenge = challengepository.Entity;
                    this.CollFiles    = file.GetAll();
                }

                contentrepository.Entity           = new Content();
                contentrepository.Entity.ContentId = this.ObjContent.ContentId;
                contentrepository.Entity.SectionId = this.ObjContent.SectionId;

                if (userId.HasValue)
                {
                    ChaellengeFollowerRepository follower = new ChaellengeFollowerRepository(session);
                    follower.Entity.UserId      = userId;
                    follower.Entity.ChallengeId = id;
                    if (follower.GetAll().Count > 0)
                    {
                        this.JoinedChallenge = true;
                    }
                }

                if (id.HasValue)
                {
                    int totalCount = 0;
                    CommentRepository   comment = new CommentRepository(session);
                    BlogEntryRepository blog    = new BlogEntryRepository(session);
                    idea.Entity.ContentId = blog.Entity.ContentId = id.Value;

                    this.CollIdeas  = idea.IdeasPaging(1, 6, out totalCount, id.Value, userId);
                    this.IdeasCount = totalCount;
                    foreach (IdeasPaging item in this.CollIdeas)
                    {
                        item.CollComment   = comment.CommentsPaging(1, 3, out totalCount, item.IdeaId.Value);
                        this.CommentsCount = totalCount;
                    }

                    this.BlogEntries      = blog.BlogContentEntriesPaging(1, 6, out totalCount);
                    this.BlogEntriesCount = totalCount;
                    foreach (BlogEntriesPaging blogEntry in this.BlogEntries)
                    {
                        blogEntry.CollComment = comment.CommentsPagingContent(1, 3, out totalCount, blogEntry.ContentId.Value);
                        this.CommentsCount    = totalCount;
                    }

                    this.TopIdeas   = idea.TopIdeas(10);
                    this.Statistics = contentrepository.GetContentStatistics(id.Value);
                }
            }

            this.CollContent = contentrepository.GetNewsRelationFrontEnd();
        }