Exemple #1
0
        public void CreatePost(PostDTOCassandra post, string username)
        {
            var session = _cluster.Connect();
            var newPost = session.Prepare("INSERT INTO posts (PostID, Username ,Text, Date) VALUES(?,?,?, ?)");

            session.Execute(newPost.Bind(post.PostID, username, post.Text, DateTime.Now));
            _stream.SynchronizeStream(session, post);
        }
Exemple #2
0
        private void DeletePost(PostDTOCassandra post, ISession session, List <string> list)
        {
            var deletePost = session.Prepare("DELETE FROM user_stream where user_id =? and last_updated_at = ?");

            foreach (var follower in list)
            {
                session.Execute(deletePost.Bind(follower, DateTime.Now));
            }
        }
Exemple #3
0
        private void AddTostream(ISession session, PostDTOCassandra post, List <string> list, List <CommentDTOCassandra> comments)
        {
            var Stream =
                session.Prepare("INSERT INTO user_stream (Username, Date , PostID , UserID , Text, Comments) VALUES(?,?,?,?,?,?)");

            foreach (var follower in list)
            {
                session.Execute(Stream.Bind(follower, DateTime.Now, post.PostID, post.username, post.Text, comments));
            }
        }
Exemple #4
0
        public void GetPosts(PostDTOCassandra post, ISession session, List <string> list)
        {
            var getPosts  = session.Prepare("Select * from posts where Username = ? ");
            var postsList = session.Execute(getPosts.Bind(post.username)).ToList();

            foreach (var post1 in postsList)
            {
                post.username = post1.GetValue <string>("Username");
                post.Date     = post1.GetValue <DateTime>("Date");
                post.Text     = post1.GetValue <string>("Text");
            }
        }
Exemple #5
0
        private void GetFollwers(PostDTOCassandra post, ISession session, List <string> list)
        {
            var getFollowerList = session.Prepare("Select followers from Followers where PostID = ? ");
            var Followers       = session.Execute(getFollowerList.Bind(post.PostID));

            list = new List <string>();

            foreach (var follower in Followers)
            {
                list = follower.GetValue <List <string> >("followers");
            }
        }
Exemple #6
0
        public void UpdatePost(PostDTOCassandra post, string username)
        {
            var session = _cluster.Connect();

            var getDate = session.Prepare("Select Date from posts where PostID = ? ");

            var updatedPost = session.Prepare(
                "Update posts set Text = ?, Date=?  where PostID = ?");

            session.Execute(updatedPost.Bind(post.Text, DateTime.Now));

            _stream.SynchronizeStream(session, post);
        }
Exemple #7
0
        public void SynchronizeStream(ISession session, PostDTOCassandra post)
        {
            session = _cluster.Connect();
            List <string> list = new List <string>();
            List <CommentDTOCassandra> comments = new List <CommentDTOCassandra>();


            GetFollwers(post, session, list);
            DeletePost(post, session, list);
            GetPosts(post, session, list);
            GetComments(comments, post.PostID, session, list);
            AddTostream(session, post, list, comments);
        }
Exemple #8
0
        public void CreateComment(PostDTOCassandra post, CommentDTOCassandra comment, string username)
        {
            var session = _cluster.Connect();


            var addComment = session.Prepare(
                "INSERT INTO comments (PostID, CommentID, Text, UserID) VALUES(?,?,?, ?)");

            session.Execute(addComment.Bind(comment.PostID, comment.CommentID, comment.Text, comment.UserID));

            var updatedPost = session.Prepare(
                "Update posts set Date=?  where PostID = ?");

            session.Execute(updatedPost.Bind(comment.CommentID, comment.PostID));



            _stream.SynchronizeStream(session, post);
        }
Exemple #9
0
 public void SyncronizeComment(PostDTOCassandra post, CommentDTOCassandra comment, string username)
 {
     _streamData.CreateComment(post, comment, username);
 }
Exemple #10
0
 public void SyncronizeExistingPost(PostDTOCassandra post, string username)
 {
     _streamData.UpdatePost(post, username);
 }
Exemple #11
0
 public void SyncronizeNewPost(PostDTOCassandra post, string username)
 {
     _streamData.CreatePost(post, username);
 }
Exemple #12
0
 public void SynchronizeStream(PostDTOCassandra post, ISession session)
 {
     _stream.SynchronizeStream(session, post);
 }