protected void CommentsListRepeater_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            switch (e.CommandName)
            {
            case "Flag":

                // Flag a comment as inappropriate
                long commentRecId = Convert.ToInt64(e.CommandArgument);

                // Check to see if this user has already flagged this comment
                if (Page.User.Identity.IsAuthenticated)
                {
                    // If user is logged in, check the user account id
                    MasterDetailFlagCommentCollection collUserAcct = new MasterDetailFlagCommentCollection()
                                                                     .Where(MasterDetailFlagComment.Columns.CommentId, commentRecId)
                                                                     .Where(MasterDetailFlagComment.Columns.CreatedBy, Page.User.Identity.Name)
                                                                     .Load();
                    if (collUserAcct.Count > 0)
                    {
                        ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "showAlertMessage",
                                                            "alert('Comment has already been flagged, and will be reviewed shortly.');", true);
                        return;
                    }
                }

                // Check to see if this comment has been previously flagged from the same IP
                MasterDetailFlagCommentCollection collIP = new MasterDetailFlagCommentCollection()
                                                           .Where(MasterDetailFlagComment.Columns.CommentId, commentRecId)
                                                           .Where(MasterDetailFlagComment.Columns.IPAddress, Request.ServerVariables["REMOTE_ADDR"])
                                                           .Load();
                if (collIP.Count > 0)
                {
                    ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "showAlertMessage2",
                                                        "alert('Comment has already been flagged, and will be reviewed shortly.');", true);
                    return;
                }

                MasterDetailFlagComment flagRec = new MasterDetailFlagComment();
                flagRec.CommentId = commentRecId;
                flagRec.IPAddress = Request.ServerVariables["REMOTE_ADDR"];
                flagRec.CreatedBy = Page.User.Identity.IsAuthenticated ? Page.User.Identity.Name : "Anonymous";
                flagRec.Save();

                ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "showAlertMessage3",
                                                    "alert('This comment is now flagged to be reviewed by a website administrator.');", true);
                break;

            default:
                break;
            }
        }
Exemple #2
0
        public void Insert(long CommentId, string IPAddress, string Reason)
        {
            MasterDetailFlagComment item = new MasterDetailFlagComment();

            item.CommentId = CommentId;

            item.IPAddress = IPAddress;

            item.Reason = Reason;

            item.CreatedOn = DateTime.Now;

            item.CreatedBy = UserName;


            item.Save(UserName);
        }
Exemple #3
0
        public void Update(long Id, long CommentId, string IPAddress, string Reason)
        {
            MasterDetailFlagComment item = new MasterDetailFlagComment();

            item.MarkOld();
            item.IsLoaded = true;

            item.Id = Id;

            item.CommentId = CommentId;

            item.IPAddress = IPAddress;

            item.Reason = Reason;

            item.Save(UserName);
        }
Exemple #4
0
        public void InsertAndReturnIdentity(long CommentId, string IPAddress, string Reason, out object newId)
        {
            MasterDetailFlagComment item = new MasterDetailFlagComment();

            item.CommentId = CommentId;

            item.IPAddress = IPAddress;

            item.Reason = Reason;

            item.CreatedOn = DateTime.Now;

            item.CreatedBy = UserName;


            item.Save(UserName);

            newId = item.Id;
        }
        protected void CommentsListRepeater_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            switch (e.CommandName)
            {
            case "Delete":
                int recId = Convert.ToInt32(e.CommandArgument);
                // Delete the comment record.  Cascase delete will remove flag records as well.
                MasterDetailComment.Delete(recId);
                BindData();
                break;

            case "Accept":
                int recId2 = Convert.ToInt32(e.CommandArgument);
                // Accept the comment, and clear all flag records.
                MasterDetailFlagComment.Delete(MasterDetailFlagComment.Columns.CommentId, recId2);
                BindData();
                break;

            default:
                break;
            }
        }
Exemple #6
0
 public bool Delete(object Id)
 {
     return(MasterDetailFlagComment.Delete(Id) == 1);
 }
Exemple #7
0
 public bool Destroy(object Id)
 {
     return(MasterDetailFlagComment.Destroy(Id) == 1);
 }