Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Assigning the ID of the post to postId variable.
            int.TryParse(Page.RouteData.Values["Id"].ToString(), out int postId);
            postID = postId;

            // Setting the comment section disabled if the user is not logged in.
            if (Session["UserId"] != null)
            {
                userID = Convert.ToInt32(Session["UserId"]);
            }
            else
            {
                txtComment.Enabled = false;
            }

            //Gets the  specific post the user have clicked
            userPost = Repositories.PostRepo.GetPost(postId);
            if (userPost.PostId == 0)
            {
                Response.Redirect("/NotFoundPage.aspx");
            }
            user         = Repositories.UserRepo.GetUser(userPost.UserId);
            lbTitle.Text = userPost.Title;
            ShowPost();

            // POSTID
            List <Comment> comments = CommentRepo.GetComments(postId);

            CommentSection.Comments = comments;

            // Fetching recent posts
            posts = Repositories.PostRepo.GetPosts();
            var btns = new List <Button>
            {
                btnPost1, btnPost2, btnPost3, btnPost4, btnPost5
            };

            for (int i = 0; i < posts.Count && i < 5; i++)
            {
                btns[i].Text = posts[i].Category + ": " + posts[i].Title;
                //btnPost1.Text = posts[0].Category + ": " + posts[0].Title;
                //btnPost2.Text = posts[1].Category + ": " + posts[1].Title;
                //btnPost3.Text = posts[2].Category + ": " + posts[2].Title;
                //btnPost4.Text = posts[3].Category + ": " + posts[3].Title;
                //btnPost5.Text = posts[4].Category + ": " + posts[4].Title;
            }
        }
Esempio n. 2
0
        public List <Comment> GetComments()
        {
            var list2 = repo.GetComments();

            return(list2);
        }
Esempio n. 3
0
        public IEnumerable <Comment> GetComments()
        {
            var list = repo.GetComments();

            return(list);
        }