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"); } } }
public void ChangePassword(int id, string newPassword, string name) { var user = new UserPoco { Name = name, Password = newPassword, UserId = id }; this.Database.Update(user); }
public static UserPoco AccountToUserPoco() { var userPoco = new UserPoco { Name = Account.Name, Password = Account.Password, UserId = Account.Id }; return(userPoco); }
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); }
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); }
public List <CommentPoco> GetUserComments(UserPoco poco) { return(this.Database.Query <CommentPoco>("SELECT * FROM comments WHERE user_id=@i;", new NpgsqlParameter("i", poco.UserId))); }
public List <PostPoco> GetAllUsersPosts(UserPoco user) { return(this.Database.Query <PostPoco>("SELECT * FROM posts WHERE user_id=@i", new NpgsqlParameter("i", user.UserId))); }