Пример #1
0
        internal static QuizModel SelectLatestQuiz()
        {
            using (IDbConnection conn = new SQLiteConnection(LoadConnectionString()))
            {
                string    SQLite = "SELECT * FROM Quizes WHERE Id=(SELECT MAX(Id) FROM Quizes)";
                QuizModel output = conn.Query <QuizModel>(SQLite, new DynamicParameters()).First();


                return(output);
            }
        }
Пример #2
0
        public static int InsertQuiz(QuizModel quiz)
        {
            try
            {
                using (IDbConnection conn = new SQLiteConnection(LoadConnectionString()))
                {
                    conn.Execute("INSERT INTO QUIZES(Name) VALUES (@Name)", quiz);
                }
            }
            catch (Exception)
            {
                return(-1);
            }


            return(quiz.Id);
        }
Пример #3
0
        private void FullQuiz(object obj)
        {
            AddNewQuiz(null);
            int exitCode;

            do
            {
                AskOneQuestionAndItsAnswersAtTheTime();
                Menu.Menu yesNoMenu = new YesNoMenu();
                exitCode = yesNoMenu.Start();
            } while (exitCode != 0);

            QuizModel            latestQuiz     = SQLiteDataAccess.SelectLatestQuiz();
            List <QuestionModel> questionsCount = SQLiteDataAccess.SelectQuestionsByQuizesId(latestQuiz.Id);

            Console.WriteLine($"{questionsCount.Count} x Questions Have Been Added To Quiz: {latestQuiz.Name}");
            Console.ReadKey();
        }
Пример #4
0
        private void DeleteQuizesById(object obj)
        {
            QuizModel deletedQuiz = SQLiteDataAccess.SelectQuizById((int)obj);

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

                Console.WriteLine("Poprawnie usunieto z bazy pytan pytanie: \n");
                Console.WriteLine(deletedQuiz);
            }
            catch (Exception)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Nie udalo sie usunac pytania.");
                Console.ResetColor();
            }

            Console.ReadKey(true);
        }