示例#1
0
        protected void ViewCommentsEvent(object sender, EventArgs e)
        {
            PostCard parentPost = sender as PostCard;
            int      postId     = parentPost.PostId;

            Session["CurrentParentPost"] = postId;
            Exception ex = null;

            foreach (RepeaterItem i in RepeaterPosts.Items)
            {
                PostCard pc = i.FindControl("postCard") as PostCard;
                if (pc.PostId != postId)
                {
                    i.Visible = false;
                }
            }
            divComments.Visible = true;
            List <(string, dynamic, Type)> filter = new List <(string, dynamic, Type)>();

            filter.Add(DBObjCreator.CreateFilter("CommentPostId", postId, typeof(int)));
            List <object[]> records  = DBObjCreator.ReadDBObjsWithWhere("TP_FindCommentsForPost", ref ex, filter);
            List <Comment>  comments = new List <Comment>();

            records.ForEach(r => comments.Add(DBObjCreator.CreateObj <Comment>(r, typeof(Comment))));
            repeaterComments.DataSource = comments;
            repeaterComments.DataBind();
        }
示例#2
0
 private void TagSearch(string tag)
 {
     if (int.Parse(Session["CurrentView"].ToString()) == ALL)
     {
         foreach (RepeaterItem i in repeaterAll.Items)
         {
             PostCard pc    = i.FindControl("postCard") as PostCard;
             int      index = pc.PostTagList.IndexOf(tag.Trim());
             if (pc.PostTagList.Count == 0 || index == -1)
             {
                 i.Visible = false;
             }
         }
     }
     if (int.Parse(Session["CurrentView"].ToString()) == FOLLOW)
     {
         foreach (RepeaterItem i in repeaterFollow.Items)
         {
             PostCard pc    = i.FindControl("postCard") as PostCard;
             int      index = pc.PostTagList.IndexOf(tag.Trim());
             if (pc.PostTagList.Count == 0 || index == -1)
             {
                 i.Visible = false;
             }
         }
     }
 }
示例#3
0
        protected void repeaterAll_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            PostCard pc   = e.Item.FindControl("postCard") as PostCard;
            Post     post = e.Item.DataItem as Post;

            if (post.PostPhoto.Equals("fake.png"))
            {
                pc.PostImage = post.PostPhoto;
                pc.ChangeImageVisibility(); //True by default, change to false
            }
            else
            {
                pc.PostImage = post.PostPhoto;
            }

            pc.PostText     = post.PostText;
            pc.PostUsername = post.Username;
            pc.Likes        = post.Likes.ToString();
            pc.PostId       = post.Id;
            pc.PostDate     = post.PostDate;
            pc.PostTagList  = new List <string>();
            pc.TagSearch   += new EventHandler(TagSearchEvent);
            if (Session["Username"] != null)
            {
                pc.DisableFollowButton(Session["Username"].ToString());
            }
            if (Session["Guest"] != null)
            {
                pc.EnableGuestRestrictions();
            }
        }
示例#4
0
        protected void SetupPostCardEvents()
        {
            foreach (RepeaterItem i in RepeaterPosts.Items)
            {
                PostCard pc = i.FindControl("postCard") as PostCard;

                pc.ViewComments += new EventHandler(ViewCommentsEvent);
            }
        }
示例#5
0
        protected void SetupPostCardEvents()
        {
            foreach (RepeaterItem i in repeaterAll.Items)
            {
                PostCard pc = i.FindControl("postCard") as PostCard;
                pc.TagSearch    += new EventHandler(TagSearchEvent);
                pc.ViewComments += new EventHandler(ViewCommentsEvent);
            }

            foreach (RepeaterItem i in repeaterFollow.Items)
            {
                PostCard pc = i.FindControl("postCard") as PostCard;
                pc.TagSearch    += new EventHandler(TagSearchEvent);
                pc.ViewComments += new EventHandler(ViewCommentsEvent);
            }
        }
示例#6
0
        protected void repeaterComments_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            PostCard pc      = e.Item.FindControl("postCard") as PostCard;
            Comment  comment = e.Item.DataItem as Comment;

            pc.PostText     = comment.CommentText;
            pc.PostUsername = comment.CommentUsername;
            pc.EnableCommentRestrictions();
            pc.PostId = comment.Id;
            if (Session["Username"] != null)
            {
                pc.DisableFollowButton(Session["Username"].ToString());
            }
            if (Session["Guest"] != null)
            {
                pc.EnableGuestRestrictions();
            }
        }
示例#7
0
        protected void RepeaterPosts_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            PostCard pc   = e.Item.FindControl("postCard") as PostCard;
            Post     post = e.Item.DataItem as Post;

            if (post.PostPhoto.Equals("fake.png"))
            {
                pc.ChangeImageVisibility(); //True by default, change to false
            }
            else
            {
                pc.PostImage = post.PostPhoto;
            }

            pc.PostDate     = post.PostDate;
            pc.PostId       = post.Id;
            pc.PostText     = post.PostText;
            pc.PostUsername = post.Username;
            pc.Likes        = post.Likes.ToString();
        }
示例#8
0
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            Greeting.InnerText = "Search Results";
            ShowAllPosts();
            repeaterAll.Items.OfType <RepeaterItem>().ToList().ForEach(i => i.Visible = true);
            string tagValue = txtSearch.Text;

            if (string.IsNullOrEmpty(tagValue) && divAdvSearch.Visible == false)
            {
                lblSearchError.Visible = true;
                lblSearchError.Text    = "Must have at least one search critera";
                return;
            }
            else if (!string.IsNullOrEmpty(tagValue))
            {
                if (!(tagValue.ToCharArray()[0] == '#'))
                {
                    tagValue = $"#{tagValue}";
                }

                TagSearch(tagValue);
            }

            if (divAdvSearch.Visible)
            {
                if (!string.IsNullOrEmpty(txtUsername.Text))
                {
                    string usernameFilter = txtUsername.Text;
                    foreach (RepeaterItem i in repeaterAll.Items)
                    {
                        PostCard pc = i.FindControl("postCard") as PostCard;
                        if (!pc.PostUsername.Equals($"@{usernameFilter}"))
                        {
                            i.Visible = false;
                        }
                    }
                }
                if (!string.IsNullOrEmpty(txtLikes.Text) && int.Parse(txtLikes.Text) > 0)
                {
                    int likes = int.Parse(txtLikes.Text);

                    foreach (RepeaterItem i in repeaterAll.Items)
                    {
                        PostCard pc      = i.FindControl("postCard") as PostCard;
                        int      pcLikes = int.Parse(pc.Likes.Split(':')[1].TrimStart());
                        if (string.IsNullOrEmpty(pc.Likes) || pcLikes < likes)
                        {
                            i.Visible = false;
                        }
                    }
                }
                if (ddlImage.SelectedIndex == 1)
                {
                    foreach (RepeaterItem i in repeaterAll.Items)
                    {
                        PostCard pc = i.FindControl("postCard") as PostCard;
                        if (pc.PostImage.Equals("fake.png"))
                        {
                            i.Visible = false;
                        }
                    }
                }
                if (ddlImage.SelectedIndex == 2)
                {
                    foreach (RepeaterItem i in repeaterAll.Items)
                    {
                        PostCard pc = i.FindControl("postCard") as PostCard;
                        if (!pc.PostImage.Equals("fake.png"))
                        {
                            i.Visible = false;
                        }
                    }
                }
                if (!string.IsNullOrEmpty(txtFilterStartDate.Text))
                {
                    DateTime startDate = DateTime.Parse(txtFilterStartDate.Text);

                    foreach (RepeaterItem i in repeaterAll.Items)
                    {
                        PostCard pc     = i.FindControl("postCard") as PostCard;
                        DateTime pcDate = DateTime.Parse(pc.PostDate.Split(':')[1].TrimStart());
                        if (pcDate < startDate.Date)
                        {
                            i.Visible = false;
                        }
                    }
                }
                if (!string.IsNullOrEmpty(txtFilterEndDate.Text))
                {
                    DateTime endDate = DateTime.Parse(txtFilterEndDate.Text);
                    foreach (RepeaterItem i in repeaterAll.Items)
                    {
                        PostCard pc     = i.FindControl("postCard") as PostCard;
                        DateTime pcDate = DateTime.Parse(pc.PostDate.Split(':')[1].TrimStart());
                        if (pcDate > endDate.Date)
                        {
                            i.Visible = false;
                        }
                    }
                }
            }
            upAllRepeater.Update();
        }