Пример #1
0
        static void DeleteThread()
        {
            Console.Clear();
            var  threadsByUser = ThreadRepository.GetThreadsByUserId(CurrentUser);
            bool isEmpty       = !threadsByUser.Any();

            if (!isEmpty)
            {
                ShowThreadsFromList(threadsByUser);
                Console.WriteLine("Which thread do you want to delete? Enter the number of the thread.");
                bool isOkay = int.TryParse(Console.ReadLine(), out int input);
                while (!isOkay || !Helper.VerifyIntBetween(1, threadsByUser.Count, input))
                {
                    Console.WriteLine("You can only enter numbers that exists in the threadnumbers. Try again.");
                    Console.WriteLine("Write the number of the thread you want to enter:");
                    isOkay = int.TryParse(Console.ReadLine(), out input);
                }
                int index     = 1;
                var tmpThread = new Thread();
                foreach (var thread in threadsByUser)
                {
                    if (index == input)
                    {
                        tmpThread = thread;
                    }
                    index++;
                }
                ThreadRepository.DeleteThread(tmpThread);
                Console.WriteLine("Thread deleted.");
            }
            else
            {
                Console.WriteLine("You don't have any threads.");
            }
            Helper.PressAnyKeyToContinue();
        }
Пример #2
0
 public void Delete(int id)
 {
     threadRepo.DeleteThread(id);
 }