예제 #1
0
        public bool InsertPostRatingNotification(Rating rating, Member member, Member friend, Post post)
        {
            using (SqlConnection con = new SqlConnection(ConnectionString))
            {

                SqlCommand cmd = new SqlCommand("uspInsertPostRatingNotification", 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("@PostID", post.PostId);

                try
                {
                    con.Open();
                    int x = cmd.ExecuteNonQuery();
                    return true;
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message.ToString());
                    return false;
                }
            }
        }
예제 #2
0
        public void LikeAPost( string sessionMemberID, int postID)
        {
            NotificationDAL notificationDAL = new NotificationDAL();

             RateAndTagDAL dal = new RateAndTagDAL();

             Post aPost = new Post(postID);

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

             string memberId = sessionMemberID;
             Member aMember = new Member(memberId);

             //Check if like exists
             if (dal.PostRatingExists(aMember, aPost) == 0)
             {
             dal.RatePost(aMember, aPost);

             List<Rating> RatingList = new List<Rating>();
             RatingList = notificationDAL.GetPostRatingID(aPost, aMember);

             Rating aRating = new Rating(RatingList[0].RatingId);

             if (RatingList.Count > 0)
             {
                 notificationDAL.InsertPostRatingNotification(aRating, aMember, aFriend, aPost);
             }
             }
             else
             {
             //MessageBox.Show("already rated by u");
             }

             aPost.PostId = postID;

             int numberofPostLikes = newsFeedDAL.CountPostLikes(aPost);
             //Updating all Clients
             Clients.updatePostLikeCount(numberofPostLikes, postID);
        }
예제 #3
0
        public List<Rating> GetPostRatingID(Post post, Member member)
        {
            using (SqlConnection con = new SqlConnection(ConnectionString))
            {
                SqlCommand cmd = new SqlCommand("uspGetPostRatingID", con);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@PostID", post.PostId);
                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;
            }
        }