예제 #1
0
        protected void rptUserPosts_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            Repeater repeater = (e.Item.FindControl("rptComment") as Repeater);

            if (e.CommandName == "Comment")
            {
                TextBox comment    = (e.Item.FindControl("hello") as TextBox);
                var     comt       = comment.Text;
                var     newComment = new BLL.Comment();
                newComment.UserId       = currentUser.Id;
                newComment.PostId       = Convert.ToInt32(e.CommandArgument);
                newComment.comment_date = DateTime.Now;
                newComment.comment_text = comment.Text;
                CommentDAO.AddComment(newComment);
                comment.Text = String.Empty;

                repeater.DataSource = CommentDAO.GetCommentByPost(Convert.ToInt32(e.CommandArgument));
                repeater.DataBind();
            }
            if (e.CommandName == "Report")
            {
                RadioButtonList report           = (e.Item.FindControl("RadioButtonList1") as RadioButtonList);
                var             userpostindex    = e.Item.ItemIndex;
                var             rpt              = report.SelectedValue;
                List <UserPost> userposts        = new List <UserPost>();
                UserPost        selecteduserpost = ((List <UserPost>)rptUserPosts.DataSource)[userpostindex];
                var             newReport        = new BLL.ReportedPost();
                newReport.postId         = selecteduserpost.Post.Id;
                newReport.reason         = rpt;
                newReport.dateCreated    = DateTime.Now;
                newReport.reporterUserId = currentUser.Id;
                ReportedPostDAO.AddReport(newReport);
            }

            if (e.CommandName == "Delete")
            {
                var      deleteId         = Convert.ToInt32(e.CommandArgument);
                var      userpostindex    = e.Item.ItemIndex;
                UserPost selecteduserpost = ((List <UserPost>)rptUserPosts.DataSource)[userpostindex];



                if (currentUser.Id == selecteduserpost.User.Id)
                {
                    CommentDAO.DeleteCommentByPostId(selecteduserpost.Post.Id);
                    ReportedPostDAO.DeleteReportedPostByPostId(selecteduserpost.Post.Id);
                    PostDAO.DeletePost(deleteId);
                    refreshGv();

                    UserCircleDAO.ChangeUserCirclePoints(
                        userId: currentUser.Id,
                        circleName: selecteduserpost.Post.CircleId,
                        points: -30,
                        source: "removing a post",
                        addNotification: true
                        );
                }
            }
        }
예제 #2
0
 public static List <ReportedPostCount> GetReportedPostCountByDate()
 {
     return(ReportedPostDAO.GetReportedPostCountByDate());
 }
예제 #3
0
 public static void DeleteReportedPostByPostId(int postId)
 {
     ReportedPostDAO.DeleteReportedPostByPostId(postId);
 }
예제 #4
0
 public static List <UserReportedPost> GetAllUserReportedPostsSortByPostId()
 {
     return(ReportedPostDAO.GetAllUserReportedPostsSortByPostId());
 }
예제 #5
0
 public static List <ReportedPost> GetAllReportedPosts()
 {
     return(ReportedPostDAO.GetAllReportedPosts());
 }
예제 #6
0
 public static ReportedPost GetReportedPostById(int reportedPostId)
 {
     return(ReportedPostDAO.GetReportedPostById(reportedPostId));
 }