public static IMessage GetQuestion(int stage)
        {
            DataBase.OpenAsync();
            IMessage quest = null;
            // TextMessage text = new TextMessage();

            //  SqliteCommand command = new SqliteCommand("SELECT * FROM QUESTIONS WHERE STAGE = '" + stage+ "' ", DataBase);
            SqliteCommand command = new SqliteCommand("SELECT * FROM [QUESTIONS] WHERE [STAGE] = " + stage, DataBase);
            var           reader  = command.ExecuteReader();

            while (reader.Read())

            {
                if (reader.GetString(0) == "0")
                {
                    TextMessage text = new TextMessage();

                    text.Stage     = int.Parse(reader.GetString(1));
                    text.Message   = reader.GetString(2).ToString();
                    text.NextStage = int.Parse(reader.GetString(3));
                    quest          = text;
                }

                else if (reader.GetString(0) == "1")
                {
                    Question quest1 = new Question();
                    quest1.Stage = int.Parse(reader.GetString(1)); quest1.Message = reader.GetString(2).ToString();

                    reader.Close();
                    command = new SqliteCommand("SELECT * FROM ANSWERS WHERE IdQuestion=" + stage, DataBase);
                    reader  = command.ExecuteReader();
                    while (reader.Read())
                    {
                        quest1.Answers.Add(new Answer(reader.GetString(1), int.Parse(reader.GetString(2))));
                    }
                    quest = quest1;
                }

                else if (reader.GetString(0) == "2")
                {
                    ImageMessage text = new ImageMessage();

                    text.Stage      = int.Parse(reader.GetString(1));
                    text.Message    = reader.GetString(2).ToString();
                    text.NextStage  = int.Parse(reader.GetString(3));
                    text.UrlMessage = reader.GetString(4);
                    quest           = text;
                }

                else if (reader.GetString(0) == "3")
                {
                    InlineImageGallery gallery = new InlineImageGallery();
                    gallery.Stage      = int.Parse(reader.GetString(1));
                    gallery.Message    = reader.GetString(2).ToString();
                    gallery.NextStage  = int.Parse(reader.GetString(3));
                    gallery.UniqueName = reader.GetString(4);
                    reader.Close();
                    command = new SqliteCommand("SELECT * FROM IMAGES WHERE StageImageGallery=" + stage, DataBase);
                    reader  = command.ExecuteReader();
                    while (reader.Read())

                    {
                        gallery.ImageGalleries.Add(new ImageGallery(int.Parse(reader.GetString(0)), reader.GetString(1), reader.GetString(2)));
                    }
                    quest = gallery;
                }


                else if (reader.GetString(0) == "4")
                {
                    PhoneMessage text = new PhoneMessage();

                    text.Stage     = int.Parse(reader.GetString(1));
                    text.Message   = reader.GetString(2).ToString();
                    text.NextStage = int.Parse(reader.GetString(3));
                    quest          = text;
                }
            }

            DataBase.CloseAsync();
            return(quest);
        }
        public static void AddMessqges(IMessage message)
        {
            DataBase.OpenAsync();
            switch (typeDict[message.GetType()])
            {
            case 5:     //PhoneMessage - 4
            {
                Question question = (Question)message;

                // SQLiteCommand insertSQL = new SQLiteCommand("INSERT INTO Book (Id, Title, Language, PublicationDate, Publisher, Edition, OfficialUrl, Description, EBookFormat) VALUES (?,?,?,?,?,?,?,?,?)", sql_con);
                SqliteCommand command = new SqliteCommand("INSERT INTO QUESTIONS (TYPEMESSAGE, Stage, Message) VALUES (@TypeMessage, @Stage, @Message)", DataBase);
                //   command.Parameters.Add(question.IdQuestion);
                command.Parameters.AddWithValue("TypeMessage", typeDict[message.GetType()]);
                command.Parameters.AddWithValue("Stage", question.Stage);
                command.Parameters.AddWithValue("Message", question.Message);
                command.ExecuteNonQuery();
                foreach (Answer an in question.Answers)
                {
                    SqliteCommand command2 = new SqliteCommand("INSERT INTO ANSWERS (IdQuestion, RightAnswer, NextStage) VALUES (@IdQuestion, @RightAnswer, @NextStage)", DataBase);

                    command2.Parameters.AddWithValue("IdQuestion", question.Stage);
                    command2.Parameters.AddWithValue("RightAnswer", an.RightAnswer);
                    command2.Parameters.AddWithValue("NextStage", an.NextStage);
                    command2.ExecuteNonQuery();
                }
                ;

                break;
            }


            case 4:     //PhoneMessage - 4
            {
                PhoneMessage  question = (PhoneMessage)message;
                SqliteCommand command  = new SqliteCommand("INSERT INTO QUESTIONS (TYPEMESSAGE, Stage, Message, Nextstage) VALUES (@TypeMessage, @Stage, @Message, @Nextstage)", DataBase);
                command.Parameters.AddWithValue("TypeMessage", typeDict[message.GetType()]);
                command.Parameters.AddWithValue("Stage", question.Stage);
                command.Parameters.AddWithValue("Message", question.Message);
                command.Parameters.AddWithValue("Nextstage", question.NextStage);
                command.ExecuteNonQuery();

                break;
            }

            case 3:     //InlineGallery - 3
            {
                InlineImageGallery question = (InlineImageGallery)message;

                // SQLiteCommand insertSQL = new SQLiteCommand("INSERT INTO Book (Id, Title, Language, PublicationDate, Publisher, Edition, OfficialUrl, Description, EBookFormat) VALUES (?,?,?,?,?,?,?,?,?)", sql_con);
                SqliteCommand command = new SqliteCommand("INSERT INTO QUESTIONS (TYPEMESSAGE, Stage, Message, NextStage) VALUES (@TypeMessage, @Stage, @Message, @NextStage)", DataBase);
                //   command.Parameters.Add(question.IdQuestion);
                command.Parameters.AddWithValue("TypeMessage", typeDict[message.GetType()]);
                command.Parameters.AddWithValue("Stage", question.Stage);
                command.Parameters.AddWithValue("Message", question.Message);
                command.Parameters.AddWithValue("NextStage", question.NextStage);
                command.ExecuteNonQuery();
                foreach (ImageGallery an in question.ImageGalleries)
                {
                    SqliteCommand command2 = new SqliteCommand("INSERT INTO IMAGES (StageImageGallery, URLImage, Description) VALUES (@Stage, @URL, @Description)", DataBase);
                    command2.Parameters.AddWithValue("Stage", question.Stage);
                    command2.Parameters.AddWithValue("URL", an.URLImage);
                    command2.Parameters.AddWithValue("Description", an.Descriptipon);
                    command2.ExecuteNonQuery();
                }



                break;
            }

            case 2:     //ImageMessage - 2
            {
                break;
            }

            case 1:     //Question - 1
            {
                Question question = (Question)message;

                // SQLiteCommand insertSQL = new SQLiteCommand("INSERT INTO Book (Id, Title, Language, PublicationDate, Publisher, Edition, OfficialUrl, Description, EBookFormat) VALUES (?,?,?,?,?,?,?,?,?)", sql_con);
                SqliteCommand command = new SqliteCommand("INSERT INTO QUESTIONS (TYPEMESSAGE, Stage, Message) VALUES (@TypeMessage, @Stage, @Message)", DataBase);
                //   command.Parameters.Add(question.IdQuestion);
                command.Parameters.AddWithValue("TypeMessage", typeDict[message.GetType()]);
                command.Parameters.AddWithValue("Stage", question.Stage);
                command.Parameters.AddWithValue("Message", question.Message);
                command.ExecuteNonQuery();
                foreach (Answer an in question.Answers)
                {
                    SqliteCommand command2 = new SqliteCommand("INSERT INTO ANSWERS (IdQuestion, RightAnswer, NextStage) VALUES (@IdQuestion, @RightAnswer, @NextStage)", DataBase);

                    command2.Parameters.AddWithValue("IdQuestion", question.Stage);
                    command2.Parameters.AddWithValue("RightAnswer", an.RightAnswer);
                    command2.Parameters.AddWithValue("NextStage", an.NextStage);
                    command2.ExecuteNonQuery();
                }


                break;
            }

            case 0:     //Text message - 0
            {
                TextMessage   question = (TextMessage)message;
                SqliteCommand command  = new SqliteCommand("INSERT INTO QUESTIONS (TYPEMESSAGE, Stage, Message, Nextstage) VALUES (@TypeMessage, @Stage, @Message, @Nextstage)", DataBase);
                command.Parameters.AddWithValue("TypeMessage", typeDict[message.GetType()]);
                command.Parameters.AddWithValue("Stage", question.Stage);
                command.Parameters.AddWithValue("Message", question.Message);
                command.Parameters.AddWithValue("Nextstage", question.NextStage);
                command.ExecuteNonQuery();

                break;
            }

            default:
            {
                break;
            }
            }
            DataBase.CloseAsync();
        }