예제 #1
0
        public static void ViewAccountPosts()
        {
            var user = new UserPoco {
                Name = Account.Name, Password = Account.Password, UserId = Account.Id
            };

            using (var conn = new NpgsqlConnection(ConnectionString))
            {
                var database = new Database(conn);
                var service  = new Service(database);
                var posts    = service.GetAllUsersPosts(user);

                if (posts.Count > 0)
                {
                    var choosedPost = Post.ChoosePostInterface(posts);

                    if (choosedPost != null)
                    {
                        ChoosePost(choosedPost);
                    }
                }
                else
                {
                    Console.WriteLine(
                        "You don't have any posts yet! create your first post by typing 'post-create' !\n");
                }
            }
        }
예제 #2
0
        public void ChangePassword(int id, string newPassword, string name)
        {
            var user = new UserPoco {
                Name = name, Password = newPassword, UserId = id
            };

            this.Database.Update(user);
        }
예제 #3
0
        public static UserPoco AccountToUserPoco()
        {
            var userPoco = new UserPoco {
                Name = Account.Name, Password = Account.Password, UserId = Account.Id
            };

            return(userPoco);
        }
예제 #4
0
        public void Rename(int id, string password, string newName)
        {
            Console.WriteLine($"Id:{id}|Password:{password}|Name:{newName}");
            var user = new UserPoco {
                Name = newName, Password = password, UserId = id
            };

            this.Database.Update(user);
        }
예제 #5
0
        public UserPoco RegisterUser(string name, string password)
        {
            var userPoco = new UserPoco {
                Name = name, Password = password
            };
            int userPocoId = this.Database.Insert(userPoco);

            userPoco.UserId = userPocoId;

            return(userPoco);
        }
예제 #6
0
 public List <CommentPoco> GetUserComments(UserPoco poco)
 {
     return(this.Database.Query <CommentPoco>("SELECT * FROM comments WHERE user_id=@i;", new NpgsqlParameter("i", poco.UserId)));
 }
예제 #7
0
 public List <PostPoco> GetAllUsersPosts(UserPoco user)
 {
     return(this.Database.Query <PostPoco>("SELECT * FROM posts WHERE user_id=@i",
                                           new NpgsqlParameter("i", user.UserId)));
 }