Esempio n. 1
0
        protected void SubmitEdit_Click(object sender, EventArgs e)
        {
            CommentManagementBO bo = new CommentManagementBO();
            //A stupid little hack I'm having to put in, because my properties keep getting reset to null
            CommentVO commentVO = bo.GetComment(Convert.ToInt32(commentID.Text));

            try {
                //Check for no text
                if (editTextBox.Text.Equals(""))
                {
                    throw new Exception(NO_TEXT_EXCEPTION);
                }

                //Edit comment
                string comText = editTextBox.Text;
                comText = Server.HtmlEncode(comText);
                comText = comText.Replace(Environment.NewLine, "<br/>");
                commentVO.CommentContents = comText;
                bo.UpdateComment(commentVO);
                this.Visible = false;
                Response.Redirect(Request.Url.ToString());
            }
            catch (Exception exc) {
                errorLabel.Text = exc.Message;
            }
        }
Esempio n. 2
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. 3
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());
                }
            }
        }