/// <summary>
        /// function to add a dictionary to the database
        /// </summary>
        /// <param name="type">The name of the dictionary</param>
        /// <param name="Slide_URL">Where the Silde is store</param>
        public void addDictionary(string type, string Slide_URL)
        {
            using (PlanetariumDataContext db = new PlanetariumDataContext())
            {

                Dictionary dictionary = new Dictionary { Type = type, Slide_URL = Slide_URL };
                db.Dictionaries.InsertOnSubmit(dictionary);
                db.SubmitChanges();
            }
        }
        /// <summary>
        /// function that adds a keyword to the specified dictionary
        /// </summary>
        /// <param name="dictionary">dictionary to add keyword to</param>
        /// <param name="phrase">the phrase to add to the dictionary specified</param>
        /// <param name="slide_num">the number of the slide</param>
        public void addKeyword(string dictionary, string phrase, int slide_num)
        {
            using (var db = new PlanetariumDataContext())
            {
                Dictionary cat = db.Dictionaries.Single(a => a.Type.Equals(dictionary));
                Keyword key = new Keyword { Dictionary_ID = cat.Dictionary_ID, Phrase = phrase, Slide_Num = slide_num };

                db.Keywords.InsertOnSubmit(key);
                db.SubmitChanges();

            }
        }
 /// <summary>
 /// function to update the phrase for a given keyword in a dictionary
 /// </summary>
 /// <param name="phrase">old phrase to update</param>
 /// <param name="newPhrase">new phrase to update to</param>
 /// <param name="dictionary">name of dictionary to update</param>
 public void updateKeywordPhrase(string phrase, string newPhrase, string dictionary)
 {
     using (var db = new PlanetariumDataContext())
     {
         Keyword key = db.Keywords.Single(a => a.Phrase.Equals(phrase) && a.Dictionary.Type.Equals(dictionary));
         key.Phrase = newPhrase;
         db.SubmitChanges();
     }
 }
 /// <summary>
 /// function to update the dictionary URL
 /// </summary>
 /// <param name="type">the name of the dictionary to update</param>
 /// <param name="newSlide_URL">new slide name to replace in for the dictionary</param>
 public void updateDictionaryURL(string type, string newSlide_URL)
 {
     using (var db = new PlanetariumDataContext())
     {
         var result = db.Dictionaries.Single(a => a.Type.Equals(type));
         result.Slide_URL = newSlide_URL;
         db.SubmitChanges();
     }
 }
        /// <summary>
        /// function that removes a keyword from a dictionary
        /// </summary>
        /// <param name="phrase">phrase to remove of the specified dictionary</param>
        /// <param name="dictionary">dictionary to remove it to</param>
        public void removeKeyword(string phrase, string dictionary)
        {
            using (var db = new PlanetariumDataContext())
            {
                try
                {
                    Keyword key = db.Keywords.Single(a => a.Dictionary.Type.Equals(dictionary) && a.Phrase.Equals(phrase));
                    int slide_num = key.Slide_Num;

                    if (slide_num == getAllKeywordsInDictionary(dictionary).Count)
                    {
                        db.Keywords.DeleteOnSubmit(key);
                        db.SubmitChanges();
                    }
                    else
                    {
                        db.Keywords.DeleteOnSubmit(key);
                        db.SubmitChanges();
                        var list = from a in db.Keywords where a.Slide_Num > slide_num select a;

                        foreach (var n in list)
                        {
                            n.Slide_Num -= 1;
                            db.SubmitChanges();
                        }
                    }
                }
                catch (Exception)
                {

                }
            }
        }
        /// <summary>
        /// function to remove a dictionary from the database
        /// with related slide in the keyword dictionary
        /// </summary>
        /// <param name="type">the name of the dictionary to remove</param>
        public void removeDictionary(string type)
        {
            using (var db = new PlanetariumDataContext())
            {
                try
                {
                    var result = db.Dictionaries.Single(a => a.Type.Equals(type));

                    int id = result.Dictionary_ID;

                    List<Keyword> keywords = new List<Keyword>();

                    keywords = (from a in db.Keywords
                                where a.Dictionary_ID == id
                                select a).ToList();

                    db.Keywords.DeleteAllOnSubmit(keywords);
                    db.SubmitChanges();
                    db.Dictionaries.DeleteOnSubmit(result);
                    db.SubmitChanges();
                }
                catch (Exception)
                {

                }
            }
        }