Esempio n. 1
0
        protected void LoadCommentDetails()
        {
            CommentManagementBO bo = new CommentManagementBO();
            UserManagementBO userBO = new UserManagementBO();
            CommentVO vo = bo.GetComment(commentID);
            comVO = vo;

            //Give comment space for its depth
            for (int i = 0; i < commentDepth; i++) {
                spacingLabel.Text = spacingLabel.Text + "<td width=\"25px\"></td>";
            }

            commentRating = vo.Rating;
            string username = userBO.GetUser(vo.UserID).Username;

            userLink.Text = username;

            commentInfo.Text = " rated at " +
                                commentRating + " points, posted " +
                                bo.FormatePostTime(vo.PostDate);

            commentContents.Text = "<p>" + vo.CommentContents + "</p>";

            //Choose which controls to display
            if(Session["login"] == null){
                editButton.Visible = false;
                deleteButton.Visible = false;
                replyButton.Visible = false;
            }
            else if (!username.Equals(Session["login"].ToString())) {
                editButton.Visible = false;
                deleteButton.Visible = false;
            }

            //Change vote image based on whether or not it's been voted on
            if(Session["login"] != null){
                int i = bo.CheckIfVoted(commentID, userBO.GetUser(Session["login"].ToString()).UserID);
                if (i == 1) {
                    upArrow.ImageUrl = "~/Images/uparrow_voted.png";
                }
                else if (i == -1) {
                    downArrow.ImageUrl = "~/Images/downarrow_voted.png";
                }
            }
        }
Esempio n. 2
0
 protected void SubmitVote(int vote)
 {
     CommentManagementBO comBO = new CommentManagementBO();
     UserManagementBO userBO = new UserManagementBO();
     CommentVO comVO = comBO.GetComment(commentID);
     UserVO userVO;
     if (Session["login"] != null) {
         userVO = userBO.GetUser(Session["login"].ToString());
         if (comBO.CheckIfVoted(commentID, userVO.UserID) == 0) {
             comBO.SubmitVote(commentID, userVO.UserID, vote);
             commentRating += vote;
             Response.Redirect(Request.Url.ToString());
         }
     }
 }