private void DeleteAnswerById(object obj)
        {
            AnswerModel deletedAnswer = SQLiteDataAccess.SelectAnswerById((int)obj);

            try
            {
                SQLiteDataAccess.DeleteAnswerById((int)obj);


                Console.WriteLine("Poprawnie usunieto z bazy odpowiedzi odpowiedz: \n");
                Console.WriteLine(deletedAnswer);
            }
            catch (Exception)
            {
                Console.WriteLine("Nie udalo sie usunac odpowiedzi");
            }

            Console.ReadKey(true);
        }
Exemple #2
0
        private void AskOneQuestionAndItsAnswersAtTheTime()
        {
            string questionText;

            do
            {
                Console.Clear();
                Console.WriteLine("\nInput new Question:");
                Console.ForegroundColor = ConsoleColor.Blue;
                questionText            = Console.ReadLine();
                Console.ResetColor();
            } while (MyValidation.ValidateStringsWithRegex.ForQuestions(questionText));

            int           idquiz        = SQLiteDataAccess.SelectLatestQuiz().Id;
            QuestionModel questionModel = new QuestionModel(idquiz, questionText);

            SQLiteDataAccess.InsertQuestion(questionModel);

            Console.WriteLine("\nInput 4 consequtive answers. Of which only first one should be correct.");

            string correctAnswer = AddNextAnswer("Input correct answer:", ConsoleColor.Green);

            Console.WriteLine($"Saved : {correctAnswer}\n");

            string[] incorrectAnswers = new string[3];
            incorrectAnswers = Get3IncorrectAnswersFromUser(incorrectAnswers);

            var         latestQuestion = SQLiteDataAccess.SelectLatestQuestion();
            AnswerModel answerModel    = new AnswerModel(latestQuestion.Id, correctAnswer, true);

            SQLiteDataAccess.InsertAnswer(answerModel);

            for (int i = 0; i < incorrectAnswers.Length; i++)
            {
                AnswerModel _answerModel = new AnswerModel(latestQuestion.Id, incorrectAnswers[i], false);
                SQLiteDataAccess.InsertAnswer(_answerModel);
            }
            ;
        }