예제 #1
0
        public User GetUserByName(string username)
        {
            var result = _cassandraConnection.ExecuteReader(_getUserByName.Bind(new
            {
                username = username
            }));

            var userRow = result.GetRows().FirstOrDefault();

            if (userRow == null)
            {
                return(null);
            }

            return(new User
            {
                UserName = userRow.GetValue <string>("username")
            });
        }
예제 #2
0
        public List <Blog> GetBlogs()
        {
            var results = _cassandraConnection.ExecuteReader(_getAllBlogs.Bind());

            return(results.GetRows().Select(row => new Blog
            {
                Id = row.GetValue <Guid>("id"),
                Title = row.GetValue <string>("title"),
                Content = row.GetValue <string>("content"),
                CreatedTime = row.GetValue <DateTime>("date"),
                Writer = _userRepository.GetUserByName(row.GetValue <string>("writer"))
            }).ToList());
        }