public static void SavePhraseOption(PhraseOption p)
 {
     using (IDbConnection cnn = new SQLiteConnection("Data Source=" + SQLiteDBLocation))
     {
         cnn.Execute("Insert into PhraseOptions (PhraseOptionTitle)", p);
     }
 }
        /// <summary>
        /// Add a PhraseOption object to database
        /// </summary>
        /// <param name="gp">a PhraseOption object</param>
        /// <returns>True if successfull</returns>
        public static bool AddPhraseOption(PhraseOption p)
        {
            if (p != null)
            {
                string sql = "INSERT INTO PhraseOptions (" +
                             "PhraseOptionTitle," +
                             "PhraseOptionValue" +
                             ") VALUES (" +
                             "@PhraseOptionTitle," +
                             "@PhraseOptionValue)";

                using (IDbConnection cnn = new SQLiteConnection("Data Source=" + SQLiteDBLocation))
                {
                    try
                    {
                        var affectedRows = cnn.Execute(sql, p);
                    }
                    catch (Exception e)
                    {
                        if (e.Message.Contains("UNIQUE constraint failed: PhraseOptions.PhraseOptionTitle"))
                        {
                            MessageBox.Show("Cannot add new PhraseOption because the title is not unique!");
                            return(false);
                        }
                        MessageBox.Show($"Cannot update due to error: ${e.Message}");
                        return(false);
                    }
                }
                return(true);
            }
            return(false);
        }
        /// <summary>
        /// Get a PhraseOption object from unique title or ID.
        /// </summary>
        /// <param name="strTitle"></param>
        /// <returns>A PhraseOption object</returns>
        public static PhraseOption GetPhraseOption(int PhraseOptionID)
        {
            string sql = "SELECT * FROM PhraseOptions WHERE PhraseOptionID = @PhraseOptionID;";

            using (IDbConnection cnn = new SQLiteConnection("Data Source=" + SQLiteDBLocation))
            {
                //to get an ilist cnn.Query<PhraseOption>("SELECT * FROM PhraseOptions");
                PhraseOption output = cnn.QuerySingleOrDefault <PhraseOption>(sql, new { PhraseOptionID });
                return(output);
            }
        }
        /// <summary>
        /// Update a PhraseOption object
        /// </summary>
        /// <param name="strTitle"></param>
        /// <returns>True if successfull</returns>
        public static bool UpdatePhraseOption(PhraseOption p)
        {
            if (p != null)
            {
                string sql = "UPDATE PhraseOptions SET " +
                             "PhraseOptionTitle = @PhraseOptionTitle, " +
                             "PhraseOptionValue= @PhraseOptionValue" +
                             " WHERE PhraseOptionID = @PhraseOptionID;";

                using (IDbConnection cnn = new SQLiteConnection("Data Source=" + SQLiteDBLocation))
                {
                    var affectedRows = cnn.Execute(sql, p);
                }
                return(true);
            }
            return(false);
        }