예제 #1
0
        public void AddPostToUsersStreams(CPostDTO post, List <string> UsersLogins)
        {
            using (ISession session = _cluster.Connect(_keyspace))
            {
                Cassandra.Mapping.IMapper mapper = new Cassandra.Mapping.Mapper(session);

                session.UserDefinedTypes.Define(new CommentProfile().Definitions);

                StreamDTO Stream = _StreamMapper.Map <StreamDTO>(post);

                var Ids = mapper.Fetch <CUserDTO>("where \"Email\" in (?)", UsersLogins.ToArray()).ToList();
                this.AddPostToUsersStreams(post, Ids.Select(p => p.User_Id).ToList());
            }
        }
예제 #2
0
        public void AddPostToUsersStreams(CPostDTO post, List <long> UsersIds)
        {
            using (ISession session = _cluster.Connect(_keyspace))
            {
                Cassandra.Mapping.IMapper mapper = new Cassandra.Mapping.Mapper(session);

                session.UserDefinedTypes.Define(new CommentProfile().Definitions);
                StreamDTO Stream = _StreamMapper.Map <StreamDTO>(post);
                foreach (var u in UsersIds)
                {
                    Stream.User_Id = u;
                    mapper.Insert(Stream);
                }
            }
        }
예제 #3
0
        public void UpdateStreamPost(CPostDTO post, List <long> UsersIds)
        {
            using (ISession session = _cluster.Connect(_keyspace))
            {
                Cassandra.Mapping.IMapper mapper = new Cassandra.Mapping.Mapper(session);

                session.UserDefinedTypes.Define(new CommentProfile().Definitions);
                foreach (var user in UsersIds)
                {
                    mapper.Update <StreamDTO>("SET \"Likes\" =? ," +
                                              "\"Title\" =?," +
                                              "\"Body\" =?," +
                                              "\"Comments\"=?," +
                                              "\"Date\" = ?" +
                                              "where \"User_Id\" = ? and \"Post_Id\" = ? ", post.Like, post.Title, post.Body, post.Comments, post.PostCreateDate, user, post.Id);
                }
            }
        }
        public CPostDTO CreatePost(string e)
        {
            using (ISession session = _cluster.Connect(_keyspace))
            {
                IMapper mapper = new Mapper(session);

                session.UserDefinedTypes.Define(new CommentProfile().Definitions);

                var      TimeUUId = TimeUuid.NewId(DateTime.Now);
                CPostDTO post     = new CPostDTO();
                post.Id = TimeUUId;
                Console.WriteLine("Write your post");
                string x = Console.ReadLine();
                Console.WriteLine("Write title of your post");
                string t = Console.ReadLine();
                post.Title = t;
                post.Body  = x;
                mapper.Insert(post);
                return(mapper.Single <CPostDTO>("where \"Post_Id\" = ? ", TimeUUId));
            }
        }