Ejemplo n.º 1
0
        public List<Member> GetCommentOwner(Comments comments)
        {
            using (SqlConnection con = new SqlConnection(ConnectionString))
            {
                SqlCommand cmd = new SqlCommand("uspGetCommentOwner", con);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.Add(new SqlParameter("@CommentID", comments.Commentid));

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

                try
                {
                    con.Open();
                    SqlDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        Member aMember = new Member(reader["MemberID"].ToString(), reader["DisplayName"].ToString(), 1);
                        MemberList.Add(aMember);
                    }//End while
                    reader.Close();
                }
                catch (Exception e)
                {
                    System.Windows.Forms.MessageBox.Show(e.Message.ToString());
                }
                return MemberList;
            }
        }
Ejemplo n.º 2
0
        public void AddComment(string sessionMemberID, string postID, string commentTxt)
        {
            Comments comment = new Comments();
            comment.MemberId = sessionMemberID;
            comment.CommentText = commentTxt;
            Post post = new Post();
            post.PostId = int.Parse(postID);
            comment.PostId = post.PostId;
            messageDAL.InsertComment(comment);
            StringBuilder commentBuilder = new StringBuilder();

            //###################################
            //refreshing Comments
            //###################################
            DataTable comments = messageDAL.GetAllComments(post);

            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() == sessionMemberID)
                {

                    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

            }

             string commentCount = messageDAL.CountComments(post).ToString();
             string commentText = commentBuilder.ToString();

            //Updating all Clients
             Clients.updatingComments(Context.ConnectionId, commentCount, commentText, postID);
        }
Ejemplo n.º 3
0
        public int CountCommentsLikes(Comments comment)
        {
            using (SqlConnection con = new SqlConnection(ConnectionString))
            {

                SqlCommand cmd = new SqlCommand("uspCountCommentsLikes", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@CommentID", comment.Commentid));

                SqlParameter returnValue = new SqlParameter("@Return_Value", DbType.Int32);
                returnValue.Direction = ParameterDirection.ReturnValue;

                cmd.Parameters.Add(returnValue);

                con.Open();
                cmd.ExecuteNonQuery();
                int value = Int32.Parse(cmd.Parameters["@Return_Value"].Value.ToString());

                return value;

            }
        }
Ejemplo n.º 4
0
        public ArrayList GetTop2Comments(Post post)
        {
            ArrayList custArray;
            using (SqlConnection con = new SqlConnection(ConnectionString))
            {

                SqlCommand cmd = new SqlCommand("uspGetTop2Comments", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@PostID", post.PostId));

                con.Open();
                SqlDataReader dbReader = cmd.ExecuteReader();
                custArray = new ArrayList();
                while (dbReader.Read())
                {
                    Comments aCountry = new Comments(int.Parse(dbReader["CommentID"].ToString()), dbReader["CommentText"].ToString(), DateTime.Parse(dbReader["CreateDate"].ToString()), int.Parse(dbReader["PostID"].ToString()), dbReader["MemberID"].ToString());
                    custArray.Add(aCountry);
                }
                con.Close();
            }
            return custArray;
        }
Ejemplo n.º 5
0
        public DataTable GetRefreshComments(Post post, Comments comment)
        {
            using (SqlConnection con = new SqlConnection(ConnectionString))
            {

                SqlCommand cmd = new SqlCommand("uspRefreshComments", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@PostID", post.PostId);
                cmd.Parameters.AddWithValue("@LastCommentID", comment.Commentid);

                DataTable Comments = new DataTable();

                try
                {
                    con.Open();

                    da = new SqlDataAdapter(cmd);
                    da.Fill(Comments);

                }
                catch (SqlException)
                {
                    throw new ApplicationException("Error connection to database");

                }
                return Comments;

            }
        }
Ejemplo n.º 6
0
        public bool FlagComment(Comments comments)
        {
            using (SqlConnection con = new SqlConnection(ConnectionString))
            {

                SqlCommand cmd = new SqlCommand("uspFlagComment", con);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@CommentID", comments.Commentid);

                try
                {
                    con.Open();
                    int x = cmd.ExecuteNonQuery();
                    return true;
                }
                catch (Exception e)
                {
                    e.ToString();
                    return false;
                }
            }
        }
Ejemplo n.º 7
0
        public string CommentRatingNotifications()
        {
            string notification = "";

            NewsfeedDAL newsFeedDAL = new NewsfeedDAL();

            NotificationDAL notificationDAL = new NotificationDAL();

            List<Notification> NotificationsList = new List<Notification>();
            NotificationsList = notificationDAL.GetCommentRatingNotificationsForAMember(aMember);

            for (int i = 0; i < NotificationsList.Count; ++i)
            {
                #region CommentRating
                //memberlist
                List<Member> MemberList = new List<Member>();
                Member aFriend = new Member(NotificationsList[i].MemberId);
                MemberList = notificationDAL.GetMemberDisplayName(aFriend);

                string FriendDisplayName = MemberList[0].DisplayName;

                List<Comments> CommentList = new List<Comments>();
                Comments aComment = new Comments(NotificationsList[i].CommentId);
                CommentList = notificationDAL.GetCommentTextAndCreateDate(aComment);

                //memberslist
                MemberList = new List<Member>();
                Post aPost = new Post(CommentList[0].PostId);
                MemberList = notificationDAL.GetPostOwner(aPost);

                string postDisplayText = "";
                if (CommentList[0].CommentText.Length > 30)
                {
                    postDisplayText = CommentList[0].CommentText.Substring(0, 30) + "...";
                }
                else
                {
                    postDisplayText = CommentList[0].CommentText;
                }

                notification += FriendDisplayName + " liked your comment '" + postDisplayText + "' which you posted " + FormatDateTime(CommentList[0].CreateDate) + " on " + MemberList[0].DisplayName + " post\n\n";
                #endregion
            }
            return notification;
        }
Ejemplo n.º 8
0
        public void DeleteAComment(string sessionMemberID, int postID, int commentID)
        {
            NewsfeedDAL dal = new NewsfeedDAL();
             Comments aComment = new Comments(commentID);
             dal.FlagComment(aComment);
             Post aPost = new Post(postID);
               string commentCount =  messageDAL.CountComments(aPost).ToString();

               //Updating all Clients
               Clients.removeDeletedComment(Context.ConnectionId, commentCount, commentID, postID);
        }
Ejemplo n.º 9
0
        public bool InsertCommentRatingNotification(Rating rating, Member member, Member friend, Comments comments)
        {
            using (SqlConnection con = new SqlConnection(ConnectionString))
            {

                SqlCommand cmd = new SqlCommand("uspInsertCommentRatingNotification", con);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@RatingID", rating.RatingId);
                cmd.Parameters.AddWithValue("@MemberID", member.MemberId);
                cmd.Parameters.AddWithValue("@FriendID", friend.MemberId);
                cmd.Parameters.AddWithValue("@CommentID", comments.Commentid);

                try
                {
                    con.Open();
                    int x = cmd.ExecuteNonQuery();
                    return true;
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message.ToString());
                    return false;
                }
            }
        }
Ejemplo n.º 10
0
        public List<Comments> GetCommentTextAndCreateDate(Comments comment)
        {
            using (SqlConnection con = new SqlConnection(ConnectionString))
            {
                SqlCommand cmd = new SqlCommand("uspGetCommentTextAndCreateDate", con);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.Add(new SqlParameter("@CommentID", comment.Commentid));

                List<Comments> CommentsList = new List<Comments>();

                try
                {
                    con.Open();
                    SqlDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        Comments aComment = new Comments(reader["CommentText"].ToString(), DateTime.Parse(reader["CreateDate"].ToString()), int.Parse(reader["PostID"].ToString()));
                        CommentsList.Add(aComment);
                    }//End while
                    reader.Close();
                }
                catch (Exception e)
                {
                    System.Windows.Forms.MessageBox.Show(e.Message.ToString());
                }
                return CommentsList;
            }
        }
Ejemplo n.º 11
0
        public List<Rating> GetCommentRatingID(Comments comments, Member member)
        {
            using (SqlConnection con = new SqlConnection(ConnectionString))
            {
                SqlCommand cmd = new SqlCommand("uspGetCommentRatingID", con);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@CommentID", comments.Commentid);
                cmd.Parameters.AddWithValue("@MemberID", member.MemberId);

                List<Rating> RatingList = new List<Rating>();

                try
                {
                    con.Open();
                    SqlDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        Rating rating = new Rating(int.Parse(reader["RatingID"].ToString()));
                        RatingList.Add(rating);
                    }//End while
                    reader.Close();
                }
                catch (Exception e)
                {
                    System.Windows.Forms.MessageBox.Show(e.Message.ToString());
                }
                return RatingList;
            }
        }
Ejemplo n.º 12
0
        public void InsertComment(Comments comment)
        {
            using (SqlConnection dbcon = new SqlConnection(ConnectionString))
            {
                cmd = new SqlCommand("uspCommentOnPost", dbcon);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@PostID", comment.PostId);
                cmd.Parameters.AddWithValue("@MemberID", comment.MemberId);
                cmd.Parameters.AddWithValue("@CommentText", comment.CommentText);

                try
                {
                    dbcon.Open();
                    cmd.ExecuteNonQuery();
                }
                catch (SqlException)
                {
                    throw new ApplicationException("Error inserting comment in:" + comment.PostId + ".");
                }
            }
        }