예제 #1
0
        public string AddComment(int postID, string commentTxt)
        {
            Comments comment = new Comments();

            comment.MemberId    = Context.Session["memberID"].ToString();
            comment.CommentText = commentTxt;
            comment.PostId      = postID;
            messageDAL.InsertComment(comment);

            //Insert notification
            NotificationDAL notificationDAL = new NotificationDAL();

            Post aPost = new Post(postID);

            List <Member> MemberList = new List <Member>();

            MemberList = notificationDAL.GetPostOwner(aPost);
            string friendId = MemberList[0].MemberId;
            Member aFriend  = new Member(friendId);

            Member aMember = new Member(Context.Session["memberID"].ToString());

            if (aMember.MemberId != aFriend.MemberId)
            {
                notificationDAL.InsertCommentedOnPostNotification(aMember, aFriend, aPost);
            }
            //Refreshing the Comment count
            Post post = new Post();

            post.PostId = comment.PostId;


            return(messageDAL.CountComments(post).ToString());
        }
예제 #2
0
        public string[] AddCommentnRefresh(int postID, string commentTxt, int lastCommentID)
        {
            NewsfeedDAL newsfeedDAL = new NewsfeedDAL();
            MessagesDAL messageDAL = new MessagesDAL();
            Comments comment = new Comments();
            StringBuilder commentBuilder = new StringBuilder();

            //Decrypting the member ID
            comment.MemberId = Context.Session["memberID"].ToString();

            comment.CommentText = commentTxt;
            comment.PostId = postID;
            comment.Commentid = lastCommentID;
            messageDAL.InsertComment(comment);

            //Insert notification
            NotificationDAL notificationDAL = new NotificationDAL();

            Post aPost = new Post(postID);

            List<Member> MemberList = new List<Member>();
            MemberList = notificationDAL.GetPostOwner(aPost);
            string friendId = MemberList[0].MemberId;
            Member aFriend = new Member(friendId);

            Member aMember = new Member(Context.Session["memberID"].ToString());

            if (aMember.MemberId != aFriend.MemberId)
            {
                notificationDAL.InsertCommentedOnPostNotification(aMember, aFriend, aPost);
            }

            //Refreshing the Comment count
            Post post = new Post();
            post.PostId = comment.PostId;

            //###################################
            //refreshing Comments
            //###################################

            DataTable comments = newsfeedDAL.GetRefreshComments(post, comment);

            foreach (DataRow row in comments.Rows)
            {
                date = Convert.ToDateTime(row["CreateDate"]).ToString("M");

                //Building single message view box
                commentBuilder.Append("<div id='");
                commentBuilder.Append((row["CommentID"]).ToString());

                commentBuilder.Append("' class='aComment'><div class='deleteComment floatright'>");

                if ((row["MemberID"]).ToString() == Session["memberID"].ToString())
                {

                    commentBuilder.Append("<a class='btnDleteComment ui-icon ui-icon-close tip' title='Delete this comment'></a>");
                }
                else
                {
                    commentBuilder.Append("<a class='btnOpenMenuComment ui-icon ui-icon-circle-triangle-s tip' title='More options..'></a>");
                }

                commentBuilder.Append("</div><h5><a style='font-weight:normal;' ");
                commentBuilder.Append("id='" + (row["MemberID"]).ToString() + "'> ");

                commentBuilder.Append(row["Friend"].ToString());
                commentBuilder.Append("</a><span class='DateWithTime ui-corner-all floatright'>");

                Reusable_Methods reusable_Methods = new Reusable_Methods();
                date = reusable_Methods.FormatDateTime(Convert.ToDateTime(row["CreateDate"]));

                commentBuilder.Append(date);
                commentBuilder.Append("</span></h5><p>");
                commentBuilder.Append((row["CommentText"]).ToString());
                commentBuilder.Append("</p></div>");
                //End Building

            }
                        //Array with the       //number of commeents         //new comments
              var comentArray =  new string[] { messageDAL.CountComments(post).ToString(), commentBuilder.ToString()};

            return comentArray;
        }
예제 #3
0
        //  Messages message;
        protected void Page_Load(object sender, EventArgs e)
        {
            #region Get the Next/Previous Message
            //if (!String.IsNullOrEmpty(Request.Form["msgeID"].ToString()) && !String.IsNullOrEmpty(Request.Form["con"].ToString()))
            //{
            //    StringBuilder concatinater = new StringBuilder();
            //    string date = "";
            //    string con = Request.Form["con"].ToString();

            //    int i = int.Parse(Request.Form["msgeID"].ToString());
            //    {

            //    if(i == 272)
            //        Response.Write("<div class='LoginUserValidationSummary BorberRad3'>Error. Your message was not sent.</div>");

            //    }
            //    //   message.MessageId = id;
            //    Messages message = new Messages();
            //    message.MessageId = int.Parse(Request.Form["msgeID"].ToString());

            //    DataTable aMessage = test.GetNxtPreMessage(message, con);

            //    foreach (DataRow row in aMessage.Rows)
            //    {
            //        date = Convert.ToDateTime(row["DateTime"]).ToString("D");

            //        //Building single message view box
            //        concatinater.Append("<div class='SingleViewmsgeWrapper' id='");
            //        concatinater.Append(row["messageID"].ToString());
            //        concatinater.Append("'><div class='msgeHeading' ><h2> <a href='#' class=' '>");
            //        concatinater.Append(row["Friend"].ToString());
            //        concatinater.Append("</a><span class='DateWithTime floatright'>");
            //        concatinater.Append(date);
            //        concatinater.Append("</span></ h2> </div>");
            //        concatinater.Append("<p class='width100%'>");
            //        concatinater.Append(row["MessageText"].ToString());
            //        concatinater.Append("</p></div>");


            //    }
            //    Response.Write(concatinater.ToString());
            //}
            #endregion


            #region Delete a Message

            if (Request.Form["msgeID"] != null)
            {
                Messages    message = new Messages(int.Parse(Request.Form["msgeID"].ToString()));
                MessagesDAL test    = new MessagesDAL();
                test.DeleteMessage(message);
                Response.Write("<div class='msgeSentNotification blueFontTextColor BorberRad3'>Your message was deleted successfully.</div>");
            }
            #endregion


            #region Get Friend Profile
            if (Request.Form["encrypMemberID"] != null)
            {
                string frnd   = Request.Form["encrypMemberID"].ToString();
                Member friend = new Member(frnd);
                Response.Write(Request.Form["encrypMemberID"].ToString());
                Response.Redirect("~/Profile.aspx");
            }


            #endregion

            //Changed to webmethod
            #region Insert A Comment
            if (Request.Form["ID"] != null && Request.Form["pstTxt"] != null)
            {
                MessagesDAL m       = new MessagesDAL();
                Comments    comment = new Comments();
                comment.MemberId    = Session["memberID"].ToString();
                comment.CommentText = Request.Form["pstTxt"].ToString();
                comment.PostId      = int.Parse(Request.Form["ID"].ToString());
                m.InsertComment(comment);

                //Refreshing the Comment count
                Post post = new Post();
                post.PostId = comment.PostId;

                //  Response.Write(m.CountComments(post));

                var comentArray = new string[] { m.CountComments(post).ToString(), };

                //JavaScriptSerializer serializer = new JavaScriptSerializer();
                //Response.Write(serializer.Serialize(loc));
                //.Response.ContentType = "application/json";
                //End Refresh
            }
            #endregion


            #region get all Comments
            if (Request.Form["ID"] != null && Request.Form["pstTxt"] == null)
            {
                Post        post    = new Post();
                Comments    comment = new Comments();
                MessagesDAL m       = new MessagesDAL();
                string      date    = "";

                post.PostId = int.Parse(Request.Form["ID"].ToString());


                StringBuilder comnt    = new StringBuilder();
                DataTable     comments = m.GetAllComments(post);

                foreach (DataRow row in comments.Rows)
                {
                    date = Convert.ToDateTime(row["CreateDate"]).ToString("D");

                    //Building single message view box
                    comnt.Append("<div id='");
                    comnt.Append((row["CommentID"]).ToString());
                    comnt.Append("' class='aComment'><div class='deleteComment floatright'><a class='btnDleteComment'>X</a></div><h5><a style='font-weight:normal;' ");
                    comnt.Append("id='" + (row["MemberID"]).ToString() + "'> ");
                    //comnt.Append("' href='#'> ");
                    comnt.Append(row["Friend"].ToString());
                    comnt.Append("</a><span class='DateWithTime ui-corner-all floatright'>");
                    comnt.Append(date);
                    comnt.Append("</span></h5><p>");
                    comnt.Append((row["CommentText"]).ToString());
                    comnt.Append("</p></div>");
                }

                Response.Write(comnt.ToString());
                //End Refresh
            }
            #endregion
        }
예제 #4
0
        public string[] AddCommentnRefresh(int postID, string commentTxt, int lastCommentID)
        {
            NewsfeedDAL   newsfeedDAL    = new NewsfeedDAL();
            MessagesDAL   messageDAL     = new MessagesDAL();
            Comments      comment        = new Comments();
            StringBuilder commentBuilder = new StringBuilder();


            //Decrypting the member ID
            comment.MemberId = Context.Session["memberID"].ToString();

            comment.CommentText = commentTxt;
            comment.PostId      = postID;
            comment.Commentid   = lastCommentID;
            messageDAL.InsertComment(comment);

            //Insert notification
            NotificationDAL notificationDAL = new NotificationDAL();

            Post aPost = new Post(postID);

            List <Member> MemberList = new List <Member>();

            MemberList = notificationDAL.GetPostOwner(aPost);
            string friendId = MemberList[0].MemberId;
            Member aFriend  = new Member(friendId);

            Member aMember = new Member(Context.Session["memberID"].ToString());

            if (aMember.MemberId != aFriend.MemberId)
            {
                notificationDAL.InsertCommentedOnPostNotification(aMember, aFriend, aPost);
            }

            //Refreshing the Comment count
            Post post = new Post();

            post.PostId = comment.PostId;


            //###################################
            //refreshing Comments
            //###################################

            DataTable comments = newsfeedDAL.GetRefreshComments(post, comment);

            foreach (DataRow row in comments.Rows)
            {
                date = Convert.ToDateTime(row["CreateDate"]).ToString("M");

                //Building single message view box
                commentBuilder.Append("<div id='");
                commentBuilder.Append((row["CommentID"]).ToString());

                commentBuilder.Append("' class='aComment'><div class='deleteComment floatright'>");



                if ((row["MemberID"]).ToString() == Session["memberID"].ToString())
                {
                    commentBuilder.Append("<a class='btnDleteComment ui-icon ui-icon-close tip' title='Delete this comment'></a>");
                }
                else
                {
                    commentBuilder.Append("<a class='btnOpenMenuComment ui-icon ui-icon-circle-triangle-s tip' title='More options..'></a>");
                }

                commentBuilder.Append("</div><h5><a style='font-weight:normal;' ");
                commentBuilder.Append("id='" + (row["MemberID"]).ToString() + "'> ");



                commentBuilder.Append(row["Friend"].ToString());
                commentBuilder.Append("</a><span class='DateWithTime ui-corner-all floatright'>");

                Reusable_Methods reusable_Methods = new Reusable_Methods();
                date = reusable_Methods.FormatDateTime(Convert.ToDateTime(row["CreateDate"]));

                commentBuilder.Append(date);
                commentBuilder.Append("</span></h5><p>");
                commentBuilder.Append((row["CommentText"]).ToString());
                commentBuilder.Append("</p></div>");
                //End Building
            }
            //Array with the       //number of commeents         //new comments
            var comentArray = new string[] { messageDAL.CountComments(post).ToString(), commentBuilder.ToString() };

            return(comentArray);
        }
예제 #5
0
        //  Messages message;
        protected void Page_Load(object sender, EventArgs e)
        {
            #region Get the Next/Previous Message
            //if (!String.IsNullOrEmpty(Request.Form["msgeID"].ToString()) && !String.IsNullOrEmpty(Request.Form["con"].ToString()))
            //{
            //    StringBuilder concatinater = new StringBuilder();
            //    string date = "";
            //    string con = Request.Form["con"].ToString();

            //    int i = int.Parse(Request.Form["msgeID"].ToString());
            //    {

            //    if(i == 272)
            //        Response.Write("<div class='LoginUserValidationSummary BorberRad3'>Error. Your message was not sent.</div>");

            //    }
            //    //   message.MessageId = id;
            //    Messages message = new Messages();
            //    message.MessageId = int.Parse(Request.Form["msgeID"].ToString());

            //    DataTable aMessage = test.GetNxtPreMessage(message, con);

            //    foreach (DataRow row in aMessage.Rows)
            //    {
            //        date = Convert.ToDateTime(row["DateTime"]).ToString("D");

            //        //Building single message view box
            //        concatinater.Append("<div class='SingleViewmsgeWrapper' id='");
            //        concatinater.Append(row["messageID"].ToString());
            //        concatinater.Append("'><div class='msgeHeading' ><h2> <a href='#' class=' '>");
            //        concatinater.Append(row["Friend"].ToString());
            //        concatinater.Append("</a><span class='DateWithTime floatright'>");
            //        concatinater.Append(date);
            //        concatinater.Append("</span></ h2> </div>");
            //        concatinater.Append("<p class='width100%'>");
            //        concatinater.Append(row["MessageText"].ToString());
            //        concatinater.Append("</p></div>");

            //    }
            //    Response.Write(concatinater.ToString());
            //}
            #endregion

            #region Delete a Message

            if (Request.Form["msgeID"] != null)
            {

                Messages message = new Messages(int.Parse(Request.Form["msgeID"].ToString()));
                MessagesDAL test = new MessagesDAL();
                test.DeleteMessage(message);
                Response.Write("<div class='msgeSentNotification blueFontTextColor BorberRad3'>Your message was deleted successfully.</div>");

            }
            #endregion

            #region Get Friend Profile
            if (Request.Form["encrypMemberID"] != null)
            {

                string frnd = Request.Form["encrypMemberID"].ToString();
                Member friend = new Member(frnd);
                Response.Write(Request.Form["encrypMemberID"].ToString());
                Response.Redirect("~/Profile.aspx");

            }

            #endregion

            //Changed to webmethod
            #region Insert A Comment
            if (Request.Form["ID"] != null && Request.Form["pstTxt"] != null)
            {

               MessagesDAL m = new MessagesDAL();
               Comments comment = new Comments();
               comment.MemberId = Session["memberID"].ToString();
               comment.CommentText = Request.Form["pstTxt"].ToString();
               comment.PostId = int.Parse(Request.Form["ID"].ToString());
               m.InsertComment(comment);

                //Refreshing the Comment count
                Post post = new Post();
                post.PostId = comment.PostId;

              //  Response.Write(m.CountComments(post));

                var comentArray = new string[] { m.CountComments(post).ToString(), };

                //JavaScriptSerializer serializer = new JavaScriptSerializer();
                //Response.Write(serializer.Serialize(loc));
                //.Response.ContentType = "application/json";
                //End Refresh
            }
            #endregion

            #region get all Comments
            if (Request.Form["ID"] != null && Request.Form["pstTxt"] == null)
            {

                Post post = new Post();
                Comments comment = new Comments();
                MessagesDAL m = new MessagesDAL();
                string date = "";

                post.PostId = int.Parse(Request.Form["ID"].ToString());

                StringBuilder comnt = new StringBuilder();
                DataTable comments = m.GetAllComments(post);

                foreach (DataRow row in comments.Rows)
                {
                    date = Convert.ToDateTime(row["CreateDate"]).ToString("D");

                    //Building single message view box
                    comnt.Append("<div id='");
                    comnt.Append((row["CommentID"]).ToString());
                    comnt.Append("' class='aComment'><div class='deleteComment floatright'><a class='btnDleteComment'>X</a></div><h5><a style='font-weight:normal;' ");
                    comnt.Append("id='" + (row["MemberID"]).ToString() + "'> ");
                    //comnt.Append("' href='#'> ");
                    comnt.Append(row["Friend"].ToString());
                    comnt.Append("</a><span class='DateWithTime ui-corner-all floatright'>");
                    comnt.Append(date);
                    comnt.Append("</span></h5><p>");
                    comnt.Append((row["CommentText"]).ToString());
                    comnt.Append("</p></div>");

                }

                Response.Write(comnt.ToString());
                //End Refresh
            }
            #endregion
        }