static void Main(string[] args) { var repo = new SqliteInitialization(); repo.PrintVersion(); var postRepo = new SqlitePostRepository(); var threadRepo = new SqliteThreadRepository(); var userRepo = new SqliteUserRepository(); while (true) { Console.WriteLine("Write 1 to show all threads. \n" + "Write 2 to show all users. \n"); string x = ""; x = Console.ReadLine(); if (x == "1") { Console.Clear(); threadRepo.GetThreads(); while (true) { PrintThreads(threadRepo); var people = threadRepo.GetThreads(); Console.WriteLine("Write the id of the thread you want to view." + "\nWrite c to create a new thread." + "\nWrite x to go back."); string input = Console.ReadLine(); if (input == "x") { Console.Clear(); break; } if (input == "c") { Console.Clear(); Thread newThread = new Thread(); Console.WriteLine("Write a topic:"); newThread.Topic = Console.ReadLine(); Console.WriteLine("Write a text:"); newThread.Text = Console.ReadLine(); newThread.PostCount = 100; threadRepo.AddThread(newThread); Console.WriteLine("Thread added!"); continue; } int threadId = int.Parse(input); Console.Clear(); var threadCreator = userRepo.GetPersonWithIdWhoCreatedThread(threadId); Console.WriteLine("User: "******"Write 1 to add a post"); Console.WriteLine("Write 2 to edit a post"); Console.WriteLine("Write 3 to delete a post"); Console.WriteLine("Write x to go back."); string threadInput = Console.ReadLine(); if (threadInput == "x") { Console.Clear(); break; } if (threadInput == "1") { Console.WriteLine(threadId); Post newPost = new Post(); Console.WriteLine("Write a text:"); newPost.Text = Console.ReadLine(); Console.WriteLine("Write the owners ID:"); newPost.UserId = Console.ReadLine(); newPost.ThreadId = threadId.ToString(); postRepo.AddPost(newPost); var obj = threadRepo.GetThreadWithId(threadId); obj.PostCount = obj.PostCount + 1; threadRepo.UpdateThreadPostCount(obj); Console.Clear(); break; } if (threadInput == "2") { Console.WriteLine("What is the ID of the post you want to edit?"); string editPostId = Console.ReadLine(); int editPostInt = int.Parse(editPostId); Post postObject = new Post(); postObject = postRepo.GetPostWithId(editPostInt); Console.WriteLine("Write the new text."); string newText = Console.ReadLine(); postObject.Text = newText; postRepo.UpdatePost(postObject); } if (threadInput == "3") { Console.WriteLine("What is the ID of the post you want to delete?"); string deletePostId = Console.ReadLine(); int editPostInt = int.Parse(deletePostId); Post postObject = new Post(); postObject = postRepo.GetPostWithId(editPostInt); postRepo.DeletePost(postObject); var obj = threadRepo.GetThreadWithId(threadId); obj.PostCount = obj.PostCount - 1; threadRepo.UpdateThreadPostCount(obj); Console.Clear(); break; } } } continue; } if (x == "2") { Console.Clear(); userRepo.GetUsers(); PrintUsers(userRepo); continue; } x = ""; } }